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
Api endpoint is still returning the cached response (network tab size - "(disk cache)") - the response was cached on the client browser
Describe the bug
When creating api endpoint with defineCachedEventHandler or cachedEventHandler even after clearing the cache in nitro it still returns cached responses due to client browser caching the functions.
Using:
shouldBypassCache,
shouldInvalidateCache
runs them only when the response isn't cached in the browser making it impossible to bypass or invalidate it in the endpoint itself without clearing browser cache beforehand.
Additional context
Current workarounds I've found:
Adding belows code to the definedefineCachedEventHandler ensures that clients browser won't cache the function which ensures we now have full control over the cache and can invalidate it manually. We can even use the shouldBypassCache or shouldInvalidateCache. and bypass the cache on will which wasn't previously possible due to browser cache.
Creating a defineCachedFunction and then using it in defineEventHandler makes it possible to clear cache manually. This approach ensures that the client browser doesn't cache the response so we don't need to create unique headers for each request.
Note:
If this is intended behaviour please do let me know. It seems odd that it isn't mentioned in the nitro documentation (or I just haven't look for it good enough). Regardless if it is in the docs I think it might be good to mention it here: nitro cache docs.
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
Describe the bug
When creating api endpoint with defineCachedEventHandler or cachedEventHandler even after clearing the cache in nitro it still returns cached responses due to client browser caching the functions.
Using:
runs them only when the response isn't cached in the browser making it impossible to bypass or invalidate it in the endpoint itself without clearing browser cache beforehand.
Additional context
Current workarounds I've found:
Adding belows code to the definedefineCachedEventHandler ensures that clients browser won't cache the function which ensures we now have full control over the cache and can invalidate it manually. We can even use the
shouldBypassCache
orshouldInvalidateCache.
and bypass the cache on will which wasn't previously possible due to browser cache.Second workaround:
Creating a
defineCachedFunction
and then using it indefineEventHandler
makes it possible to clear cache manually. This approach ensures that the client browser doesn't cache the response so we don't need to create unique headers for each request.Note:
If this is intended behaviour please do let me know. It seems odd that it isn't mentioned in the nitro documentation (or I just haven't look for it good enough). Regardless if it is in the docs I think it might be good to mention it here: nitro cache docs.
Logs
No response
The text was updated successfully, but these errors were encountered: