Explicitly set `cache-control: no-cache` header for 404 responses
Open
Nobody has claimed this yet.
v2
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
If anyone is still getting this problem, just add this plugin to Nitro:
export default defineNitroPlugin(nitroApp => {
nitroApp.hooks.hook('error', (error, { event }) => {
if (event && (error as any).statusCode === 404) {
setHeader(event, 'cache-control', 'no-cache')
}
})
})
Originally posted by @andresilva-cc in https://github.com/unjs/nitro/issues/1742#issuecomment-2091695387
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by locating Nitro's 404 and error-response handling, then compare it with the plugin behavior shown in the issue body. Done means 404 responses explicitly include the requested cache-control: no-cache header and the behavior is covered by the project's relevant checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100