Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit ce62238

Browse files
test: mark cache field
1 parent e04856d commit ce62238

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

packages/libs/lambda-at-edge/src/default-handler.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ const handleOriginResponse = async ({
11071107
.replace(".json", ".html")}`,
11081108
Body: html,
11091109
ContentType: "text/html",
1110-
CacheControl: "public, max-age=0, s-maxage=2678400, must-revalidate"
1110+
CacheControl: "public, max-age=0, s-maxage=2678401, must-revalidate"
11111111
};
11121112

11131113
debug(region);
@@ -1178,7 +1178,7 @@ const handleOriginResponse = async ({
11781178
CacheControl ??
11791179
(hasFallback.fallback // Use cache-control from S3 response if possible, otherwise use defaults
11801180
? "public, max-age=0, s-maxage=0, must-revalidate" // fallback should never be cached
1181-
: "public, max-age=0, s-maxage=2678400, must-revalidate")
1181+
: "public, max-age=0, s-maxage=2678411, must-revalidate")
11821182
}
11831183
]
11841184
},
@@ -1343,7 +1343,7 @@ export const generatePermanentPageResponse = async (
13431343
"cache-control": [
13441344
{
13451345
key: "Cache-Control",
1346-
value: "public, max-age=0, s-maxage=2678400, must-revalidate"
1346+
value: "public, max-age=0, s-maxage=2678402, must-revalidate"
13471347
}
13481348
]
13491349
},

packages/libs/lambda-at-edge/src/services/s3.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class S3Service {
6868
Body: body,
6969
Bucket: this.options.bucketName,
7070
ContentType: contentType,
71-
CacheControl: "public, max-age=0, s-maxage=2678400, must-revalidate"
71+
CacheControl: "public, max-age=0, s-maxage=2678403, must-revalidate"
7272
})
7373
);
7474
}

packages/libs/s3-static-assets/src/index.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import filterOutDirectories from "./lib/filterOutDirectories";
66
import {
77
IMMUTABLE_CACHE_CONTROL_HEADER,
88
SERVER_NO_CACHE_CACHE_CONTROL_HEADER,
9-
SERVER_CACHE_CONTROL_HEADER
9+
SERVER_CACHE_CONTROL_HEADER,
10+
SERVER_CACHE_CONTROL_HEADER1,
11+
SERVER_CACHE_CONTROL_HEADER2,
12+
SERVER_CACHE_CONTROL_HEADER3,
13+
SERVER_CACHE_CONTROL_HEADER4,
14+
SERVER_CACHE_CONTROL_HEADER5
1015
} from "./lib/constants";
1116
import S3ClientFactory, { Credentials } from "./lib/s3";
1217
import pathToPosix from "./lib/pathToPosix";
@@ -137,7 +142,7 @@ const uploadStaticAssetsFromBuild = async (
137142
filePath: fileItem.path,
138143
cacheControl: isAbTestPath
139144
? SERVER_NO_CACHE_CACHE_CONTROL_HEADER
140-
: SERVER_CACHE_CONTROL_HEADER
145+
: SERVER_CACHE_CONTROL_HEADER1
141146
});
142147
}
143148
});
@@ -248,7 +253,7 @@ const uploadStaticAssets = async (
248253
)
249254
),
250255
filePath: pageFilePath,
251-
cacheControl: SERVER_CACHE_CONTROL_HEADER
256+
cacheControl: SERVER_CACHE_CONTROL_HEADER2
252257
});
253258
});
254259

@@ -273,7 +278,7 @@ const uploadStaticAssets = async (
273278
withBasePath(prerenderManifest.routes[key].dataRoute.slice(1))
274279
),
275280
filePath: pageFilePath,
276-
cacheControl: SERVER_CACHE_CONTROL_HEADER
281+
cacheControl: SERVER_CACHE_CONTROL_HEADER3
277282
});
278283
});
279284

@@ -293,7 +298,7 @@ const uploadStaticAssets = async (
293298
withBasePath(path.posix.join("static-pages", relativePageFilePath))
294299
),
295300
filePath: pageFilePath,
296-
cacheControl: SERVER_CACHE_CONTROL_HEADER
301+
cacheControl: SERVER_CACHE_CONTROL_HEADER4
297302
});
298303
});
299304

@@ -313,7 +318,7 @@ const uploadStaticAssets = async (
313318
withBasePath(path.posix.join("static-pages", fallback))
314319
),
315320
filePath: pageFilePath,
316-
cacheControl: SERVER_CACHE_CONTROL_HEADER
321+
cacheControl: SERVER_CACHE_CONTROL_HEADER5
317322
});
318323
});
319324

packages/libs/s3-static-assets/src/lib/constants.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@ export const IMMUTABLE_CACHE_CONTROL_HEADER =
22
"public, max-age=31536000, immutable";
33

44
export const SERVER_CACHE_CONTROL_HEADER =
5-
"public, max-age=0, s-maxage=2678400, must-revalidate";
5+
"public, max-age=0, s-maxage=2678404, must-revalidate";
6+
7+
export const SERVER_CACHE_CONTROL_HEADER1 =
8+
"public, max-age=0, s-maxage=2678405, must-revalidate";
9+
10+
export const SERVER_CACHE_CONTROL_HEADER2 =
11+
"public, max-age=0, s-maxage=2678406, must-revalidate";
12+
13+
export const SERVER_CACHE_CONTROL_HEADER3 =
14+
"public, max-age=0, s-maxage=2678407, must-revalidate";
15+
16+
export const SERVER_CACHE_CONTROL_HEADER4 =
17+
"public, max-age=0, s-maxage=2678408, must-revalidate";
18+
19+
export const SERVER_CACHE_CONTROL_HEADER5 =
20+
"public, max-age=0, s-maxage=2678409, must-revalidate";
621

722
export const DEFAULT_PUBLIC_DIR_CACHE_CONTROL =
823
"public, max-age=31536000, must-revalidate";

0 commit comments

Comments
 (0)