nitro icon indicating copy to clipboard operation
nitro copied to clipboard

The cache on the Cloudflare page does not expire

Open issue-up[bot] opened this issue 2 years ago • 6 comments

   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: [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: 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

issue-up[bot] avatar Jul 22 '23 11:07 issue-up[bot]

Maybe related to #1198

DanSnow avatar Jul 22 '23 15:07 DanSnow

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

DanSnow avatar Aug 29 '23 17:08 DanSnow

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 avatar Jun 15 '24 02:06 dimasxp

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

DanSnow avatar Jun 19 '24 05:06 DanSnow

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.

adamdehaven avatar Jul 12 '24 15:07 adamdehaven

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 true for all cache drivers on all presets, if I'm not mistaken this is currently tracked at #2378

sandros94 avatar Oct 21 '24 18:10 sandros94

https://github.com/nitrojs/nitro/issues/2378#issuecomment-2575876133

pi0 avatar Jan 07 '25 19:01 pi0