mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Update 404 static cache header to not cache (#5146)
This commit is contained in:
parent
873ac5dba8
commit
3f650e1549
|
@ -310,6 +310,7 @@ export default class Server {
|
||||||
async render404 (req, res, parsedUrl = parseUrl(req.url, true)) {
|
async render404 (req, res, parsedUrl = parseUrl(req.url, true)) {
|
||||||
const { pathname, query } = parsedUrl
|
const { pathname, query } = parsedUrl
|
||||||
res.statusCode = 404
|
res.statusCode = 404
|
||||||
|
res.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
|
||||||
return this.renderError(null, req, res, pathname, query)
|
return this.renderError(null, req, res, pathname, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,14 @@ describe('Production Usage', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should set correct Cache-Control header for static 404s', async () => {
|
||||||
|
// this is to fix where 404 headers are set to 'public, max-age=31536000, immutable'
|
||||||
|
const res = await fetch(`http://localhost:${appPort}/_next//static/common/bad-static.js`)
|
||||||
|
|
||||||
|
expect(res.status).toBe(404)
|
||||||
|
expect(res.headers.get('Cache-Control')).toBe('no-cache, no-store, max-age=0, must-revalidate')
|
||||||
|
})
|
||||||
|
|
||||||
it('should block special pages', async () => {
|
it('should block special pages', async () => {
|
||||||
const urls = ['/_document', '/_error']
|
const urls = ['/_document', '/_error']
|
||||||
for (const url of urls) {
|
for (const url of urls) {
|
||||||
|
|
Loading…
Reference in a new issue