One question on the getStaticProps and getServerSideProps.
getStaticProps would be called only at build time, since we are using that here, if we update our database with new products it would be fetched only on fresh build.
If we have used getServerSideProps with API routes, for the above use case, the new products would be reflected on a page reload/new request. Is my understanding is correct?
Indeed getStaticProps will be called at build time, independently of database updates. Although you can use the revalidate option to refresh the page after a certain delay.
getServerSideProps will pre-render the page on each request as you said, which is most often a good approach if your use case requires very frequent database updates.
So your understanding was indeed correct! 🙂
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great Article. 👏🏼
One question on the
getStaticProps
andgetServerSideProps
.getStaticProps
would be called only at build time, since we are using that here, if we update our database with new products it would be fetched only on fresh build.If we have used
getServerSideProps
with API routes, for the above use case, the new products would be reflected on a page reload/new request. Is my understanding is correct?@payapula much thanks! 🙇
Indeed
getStaticProps
will be called at build time, independently of database updates. Although you can use therevalidate
option to refresh the page after a certain delay.getServerSideProps
will pre-render the page on each request as you said, which is most often a good approach if your use case requires very frequent database updates.So your understanding was indeed correct! 🙂