-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
📚 What are you trying to do?
I've deployed our Nuxt app to Cloudflare using NuxtHub.
I'm generating OG images at runtime (the entire app is server-rendered, so pre-generating images isn't feasible) and setting a cache expiration time of 31 days.
Everything works well, except for two issues related to caching:
-
Version-based cache key invalidation
It appears that the cached data is scoped under a base that includes the current Nuxt OG Image version (see screenshot). As a result, any time a new version of the package is released, the cache is effectively invalidated—even if nothing else has changed. -
Namespace creation
For each unique route, a new KV namespace seems to be used(?)—likely because the cache key includes something like {{ogImage.version}}:{{request.pathname}}. This might cause concern for apps with many routes, for example with Cloudflare KV namespace limit.
So my question is: Is there currently a way to customize the cache key strategy?
I couldn’t find anything in the documentation, and a dive into the source code didn’t reveal an obvious solution either.
Here's our current config:
ogImage: {
runtimeCacheStorage: process.env.NODE_ENV === 'production'
? {
driver: 'cloudflare-kv-binding',
binding: 'CACHE'
}
: false,
defaults: {
cacheMaxAgeSeconds: process.env.NODE_ENV === 'production' ? 60 * 60 * 24 * 31 : 0
},
zeroRuntime: false
}🔍 What have you tried?
No response
ℹ️ Additional context
No response
