Replies: 1 comment
-
from what i have seen, the very first time when you request the page ,page.json does not have any data it is a 1kb file with no content, but when you do client side navigation and come back to the same page, a request is sent for page.json ,this time it comes back with the data to fill the page . in this scenario if you had set revalidate to 1 , and something changed in db meanwhile , Next.js will attempt to re-generate the page with every request. so you will get the latest changes (even though there was no build happening here) if you remove revalidate ,you will get the same stale data every time until the next build. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I hope this isn't a stupid question...
In the with-apollo example, from what I can understand the cache is persisted through the build step by each page including initialApolloState in the page props so that it can be picked up and added to by each subsequent page generation:
`export async function getStaticProps() {
const apolloClient = initializeApollo()
await apolloClient.query({
query: ALL_POSTS_QUERY,
variables: allPostsQueryVars,
})
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
unstable_revalidate: 1,
}
}`
I understand how this would improve the build stage as it prevents continuously refetching the shared data that appears on multiple pages, but is there a client performance cost to it? Doesn't it mean that the entire cache from the build process is included in the json exported from getStaticProps and downloaded by the client - although it's not used by the client? I can see it in my page.json in the client console.
If the performance improvement only impacts the build step (and the db server), wouldn't it be better to sacrifice these to maximise client-side performance?
Or have I completely misunderstood how this works?
A related, more specific question: is 'unstable_revalidate: 1' required for this example? I was having issues with it so I disabled it as I don't currently need incremental builds - should this cause any knock on problems?
Beta Was this translation helpful? Give feedback.
All reactions