You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to cache data at run time but I don't want to use a static cache from build time. Is there any way to avoid this?
The problem is a simple one, the first time a new instance (think K8s pod or a Lambda) starts up it will have the build time version of the app. Therefore the first user to hit this instance will see old data (e.g. old product pages, a feature flag state from a week ago etc) and then only after cacheLife.invalidate time will subsequent users will see new data. I don't want users seeing old data from back at build time.
Put another way, my experience from testing is that the cache life is from the first time the app runs, not when the build was done, meaning you can see very stale data as the first user to an instance (or any early users till invalidate passes and it rebuilds the page or component). I looked at using "await connection()" but then that removes the cache completely and isn't compatible with 'use cache'.
What I am looking for, if it exists is a way to use cache components to cache content at runtime but to not produce a build time cache which quickly gets out of date - I don't want to serve from this past a short time after the build, I want to refresh the cache. I mean to be fair a build-time cache is fine, but only if I don't serve content from it past a certain point.
Any suggestions? Maybe I could call invalidate, but where would be the right place to do this? In Instrumentation - that doesn't seem to work, says "static generation store missing"? Not sure if it is too late for the current request if I try and call it from within the current request. An invalidate endpoint doesn't really work in a lambda unfortunately
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I would like to cache data at run time but I don't want to use a static cache from build time. Is there any way to avoid this?
The problem is a simple one, the first time a new instance (think K8s pod or a Lambda) starts up it will have the build time version of the app. Therefore the first user to hit this instance will see old data (e.g. old product pages, a feature flag state from a week ago etc) and then only after cacheLife.invalidate time will subsequent users will see new data. I don't want users seeing old data from back at build time.
Put another way, my experience from testing is that the cache life is from the first time the app runs, not when the build was done, meaning you can see very stale data as the first user to an instance (or any early users till invalidate passes and it rebuilds the page or component). I looked at using "await connection()" but then that removes the cache completely and isn't compatible with 'use cache'.
What I am looking for, if it exists is a way to use cache components to cache content at runtime but to not produce a build time cache which quickly gets out of date - I don't want to serve from this past a short time after the build, I want to refresh the cache. I mean to be fair a build-time cache is fine, but only if I don't serve content from it past a certain point.
Any suggestions? Maybe I could call invalidate, but where would be the right place to do this? In Instrumentation - that doesn't seem to work, says "static generation store missing"? Not sure if it is too late for the current request if I try and call it from within the current request. An invalidate endpoint doesn't really work in a lambda unfortunately
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions