unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.83k stars 490 forks source link

The cache on the Cloudflare page does not expire #1478

Open issue-up[bot] opened 1 year ago

issue-up[bot] commented 1 year ago
   Forwarded from downstream issue: - https://github.com/nuxt/nuxt/issues/22279 by @DanSnow

### Environment - Operating System: `Darwin` - Node Version: `v20.4.0` - Nuxt Version: `3.6.5` - Nitro Version: `2.5.2` - Package Manager: `yarn@3.6.1` - 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: true` and `maxAge: 1`. https://github.com/DanSnow/nuxt-cache-test/blob/main/server/api/time.ts - Route Rule: All use the settings `swr: true`, `maxAge: 10`, and `staleMaxAge: 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_
DanSnow commented 1 year ago

Maybe related to #1198

DanSnow commented 1 year ago

I've upgraded the bug's demo to Nuxt 3.7 and Nitro 2.6, and the issue still persists.

dimasxp commented 3 months ago

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?

DanSnow commented 2 months ago

@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.

adamdehaven commented 2 months ago

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.