New next.js instance regenerates shared cache #67842
Unanswered
TimGeudens
asked this question in
Help
Replies: 1 comment
-
I have the same problem, is there a better plan? Thank you |
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
-
Summary
We are self-hosting a next.js app using app router. We have a shared disk where all instances run from. Since we use the default next.js cache it is also used for reading and writing the fetch cache and full route cache.
However we noticed that the full route cache files (.html, .meta & .rsc) are constantly regenerated. This happens every 3-10 minutes.
After doing some testing locally we noticed that a new server instance will regenerate those files no matter what.
On production when an instance restarts or when it is added by automatic scaling, this triggers a regeneration of full route files for all requests on that new instance. As a result we get quite some disk writes which we did not expect. The fetch cache however seems fine since rebuilding the page is still pretty fast.
We also tried adding a Redis cache handler but saw the same issue there (cache string gets updated when new instance comes online).
We also tried adding the build id in the config when testing locally but that did not help either.
generateBuildId: async () => { return 'build-1'; }, deploymentId: 'build-1',
Is this something that is expected or is there something we could change so that new instances just read from the existing cache?
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions