nitrojs / nitrojs/nitro

SWR working as not expected

Open
#3,396 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug nuxt v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

"engines": {
"node": "20.10.0"
},

"nuxt": "3.17.5",

Reproduction
Describe the bug

routeRules: { swr: 300 }

expectations:
cache-control: s=max-age: 300 state-while-revalidate

realty:
devTools - disable cache : true
cache-control: s=max-age: 300 state-while-revalidate
devTools - disable cache : false (second request)
cache-control: public, max-age=300, s-maxage=300

Sorry may be I don't know how browsers works or something else, but max-age (a.k.a. browser cahce) dangerous for my project, how can I resolve this?

Additional context

No response

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported Nuxt 3.17.5 behavior with routeRules configured as swr: 300, comparing cache-control headers with browser cache disabled and enabled. Done means the observed browser caching behavior is explained or corrected so the expected cache-control policy is clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.