The cache on the Cloudflare page does not expire
Forwarded from downstream issue:
|
Environment
- Operating System:
Darwin - Node Version:
v20.4.0 - Nuxt Version:
3.6.5 - Nitro Version:
2.5.2 - Package Manager:
[email protected] - Builder:
vite - User Config:
devtools,nitro,routeRules - Runtime Modules:
- - Build Modules:
-
Reproduction
source code: https://github.com/DanSnow/nuxt-cache-test demo: https://nuxt-cache-test.pages.dev
Describe the bug
Cache Configuration
- API: Use defineCachedEventHandler with the settings
swr: trueandmaxAge: 1. https://github.com/DanSnow/nuxt-cache-test/blob/main/server/api/time.ts - Route Rule: All use the settings
swr: true,maxAge: 10, andstaleMaxAge: 3. https://github.com/DanSnow/nuxt-cache-test/blob/main/nuxt.config.ts#L12
Expected Behavior
The time difference between the server and the client should be at most around 10 seconds.
Actual Behavior
As shown in the video, the server's time remains unchanged.
https://github.com/nuxt/nuxt/assets/5575082/99c02dd2-287e-4d1a-8a25-51da24c60024
Additional context
No response
Logs
No response
Maybe related to #1198
I've upgraded the bug's demo to Nuxt 3.7 and Nitro 2.6, and the issue still persists.
I've upgraded the bug's demo to Nuxt 3.7 and Nitro 2.6, and the issue still persists.
i have the same issue, did you manage to solve this problem?
@dimasxp We followed the approach of this PR and patched the Cloudflare kv driver of unstorage ourselves so that our cache uses the native Cloudflare expiration mechanism.
This is also an issue with the cloudflare-module preset when utilizing Cloudflare KV as the cache driver.
No ttl or expires is written to the KV entry, meaning it does not expire and lives eternally.
This is also an issue with the
cloudflare-modulepreset when utilizing Cloudflare KV as thecachedriver.No
ttlorexpiresis written to the KV entry, meaning it does not expire and lives eternally.
This is true for all cache drivers on all presets, if I'm not mistaken this is currently tracked at #2378
https://github.com/nitrojs/nitro/issues/2378#issuecomment-2575876133