Home > Software design >  Does getServerSideProps generates the whole page at each request at the server?
Does getServerSideProps generates the whole page at each request at the server?

Time:10-09

I learnt that getServerSideProps will generate the whole page on each request, instead of doing it at the time of build. Does getServerSideProps generates the whole page at each request at the server? or it just generates the whole page at the server IF the data has been changed in the database?

If it does generates a whole page, each request at the server, Isn't vanilla react JS doing the same thing?

(Except the fact that it is generating the page on the client's end but it is calling the APIs independent of the fact if the data has been changed or not.)

CodePudding user response:

getServerSideProps pre-renders the page on every request. That means you the page is sent with all the data filled in. That is very different from sending an empty page and making API calls.

Also there is an option to cache by setting cache-headers in response, so if the data remains the same a particular browser can cache it and the API calls are not made again.

CodePudding user response:

As long as props which is sent to page has some space to change, SSR has to occur every request. getServerSideProps is always depending on the request from client unless caching is activated.

  • Related