Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ exports[`getRoutesManifest should return routes manifest 2`] = `
Array [
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
Object {
"key": "x-xss-protection",
"value": "1; mode=block",
Expand Down Expand Up @@ -387,42 +391,6 @@ Array [
],
"path": "/static/*",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/page-data/index/page-data.json",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/page-data/sq/d/1.json",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/page-data/app-data.json",
},
Object {
"headers": Array [
Object {
Expand All @@ -432,32 +400,5 @@ Array [
],
"path": "/app-123.js",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/chunk-map.json",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/webpack.stats.json",
},
Object {
"headers": Array [
Object {
"key": "cache-control",
"value": "public, max-age=0, must-revalidate",
},
],
"path": "/_gatsby/slices/_gatsby-scripts-1.html",
},
]
`;
26 changes: 8 additions & 18 deletions packages/gatsby/src/utils/adapter/__tests__/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ describe(`getRoutesManifest`, () => {

expect(headers).toContainEqual({
headers: [
{
key: `cache-control`,
value: `public, max-age=0, must-revalidate`,
},
{ key: `x-xss-protection`, value: `1; mode=block` },
{ key: `x-content-type-options`, value: `nosniff` },
{ key: `referrer-policy`, value: `same-origin` },
Expand All @@ -172,15 +176,6 @@ describe(`getRoutesManifest`, () => {
],
path: `/static/*`,
})
expect(headers).toContainEqual({
headers: [
{
key: `cache-control`,
value: `public, max-age=0, must-revalidate`,
},
],
path: `/page-data/index/page-data.json`,
})
expect(headers).toContainEqual({
headers: [
{
Expand Down Expand Up @@ -234,6 +229,10 @@ describe(`getRoutesManifest`, () => {

expect(headers).toContainEqual({
headers: [
{
key: `cache-control`,
value: `public, max-age=0, must-revalidate`,
},
{ key: `x-xss-protection`, value: `1; mode=block` },
{ key: `x-content-type-options`, value: `nosniff` },
{ key: `referrer-policy`, value: `same-origin` },
Expand All @@ -250,15 +249,6 @@ describe(`getRoutesManifest`, () => {
],
path: `/prefix/static/*`,
})
expect(headers).toContainEqual({
headers: [
{
key: `cache-control`,
value: `public, max-age=0, must-revalidate`,
},
],
path: `/prefix/page-data/index/page-data.json`,
})
expect(headers).toContainEqual({
headers: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/utils/adapter/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const headersAreEqual = (a, b): boolean =>
const getDefaultHeaderRoutes = (pathPrefix: string): HeaderRoutes => [
{
path: `${pathPrefix}/*`,
headers: BASE_HEADERS,
headers: MUST_REVALIDATE_HEADERS,
},
{
path: `${pathPrefix}/static/*`,
Expand All @@ -319,7 +319,7 @@ const getDefaultHeaderRoutes = (pathPrefix: string): HeaderRoutes => [
const customHeaderFilter =
(route: Route, pathPrefix: string) =>
(h: IHeader["headers"][0]): boolean => {
for (const baseHeader of BASE_HEADERS) {
for (const baseHeader of MUST_REVALIDATE_HEADERS) {
if (headersAreEqual(baseHeader, h)) {
return false
}
Expand Down