Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
3f650e15
Commit
3f650e15
authored
Sep 12, 2018
by
Lin Qiu
Committed by
Tim Neutkens
Sep 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 404 static cache header to not cache (#5146)
parent
873ac5db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
index.js
server/index.js
+1
-0
index.test.js
test/integration/production/test/index.test.js
+8
-0
No files found.
server/index.js
View file @
3f650e15
...
@@ -310,6 +310,7 @@ export default class Server {
...
@@ -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
)
}
}
...
...
test/integration/production/test/index.test.js
View file @
3f650e15
...
@@ -91,6 +91,14 @@ describe('Production Usage', () => {
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment