What version of Next.js are you using?
10.0.7-canary.3
What version of Node.js are you using?
15.7.0
What browser are you using?
Chrome, Safari, curl
What operating system are you using?
macOS
How are you deploying your application?
next build, next start
Describe the Bug
Cache-Control headers are overwritten to be: Cache-Control: s-maxage=31536000, stale-while-revalidate. This header should include the public directive so that CDNs will cache the response.
As an aside, headers are not overwritten consistently. If I have the following config:
// next.config.js
module.exports = {
async headers() {
const headers = [
{
headers: [
{
key: "Cache-Control",
value:
"public, max-age=3600, s-maxage=60, stale-while-revalidate=86400",
},
],
source: "/:path*",
},
];
return headers;
},
};
Making a request to / will return the header: Cache-Control: s-maxage=31536000, stale-while-revalidate but making a request to /posts/first-post returns the header Cache-Control: public, max-age=3600, s-maxage=60, stale-while-revalidate=86400.
Expected Behavior
The headers should be overwritten consistently across all pages. The overwritten headers should include the public directive.
To Reproduce
- Clone https://github.com/nrempel/repro-cache-control-headers
- npm build && npm start
- Visit / and look at headers
- Visit /posts/first-post and look at headers
What version of Next.js are you using?
10.0.7-canary.3
What version of Node.js are you using?
15.7.0
What browser are you using?
Chrome, Safari, curl
What operating system are you using?
macOS
How are you deploying your application?
next build, next start
Describe the Bug
Cache-Control headers are overwritten to be:
Cache-Control: s-maxage=31536000, stale-while-revalidate. This header should include thepublicdirective so that CDNs will cache the response.As an aside, headers are not overwritten consistently. If I have the following config:
Making a request to
/will return the header:Cache-Control: s-maxage=31536000, stale-while-revalidatebut making a request to/posts/first-postreturns the headerCache-Control: public, max-age=3600, s-maxage=60, stale-while-revalidate=86400.Expected Behavior
The headers should be overwritten consistently across all pages. The overwritten headers should include the
publicdirective.To Reproduce