Skip to content
Discussion options

You must be logged in to vote

@Leon2xiaowu this is by design. cache.varies controls which request headers are used to generate the internal cache key (server-side differentiation), not which headers appear in the HTTP response. it tells nitro's caching layer "create separate cache entries when these request headers differ."

cache.maxAge does double duty (sets both internal TTL and the Cache-Control response header), but varies is internal only.

to also set the Vary response header for CDN/browser caching, combine both options:

// nitro.config.ts
export default defineNitroConfig({
  routeRules: {
    '/profile': {
      cache: { maxAge: 86400, varies: ['cookie', 'accept-language'] },
      headers: { 'Vary': 'Cookie, A…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Leon2xiaowu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants