@@ -54,11 +54,12 @@ const s3Client = new S3({
5454 credentials : getCredentials ( ) ,
5555} ) ;
5656
57- const CACHE_MAX_AGE = 5 * 1000 * 60 ; // 5mins
57+ const IMMUTABLE_CACHE_MAX_AGE = 1000 * 60 * 60 * 24 * 7 ; // a week
5858
5959for ( const file of artifacts ) {
6060 const filePath = path . join ( DIST_DIR , file ) ;
61- // NB: important that upload root directory is always `compass/`
61+ // TODO(SRE-4971): while we're uploading to the downloads bucket, the object
62+ // key always needs to start with `compass/`
6263 const objectKey = `compass/web/${ HEAD } /${ file } ` ;
6364
6465 console . log (
@@ -85,7 +86,9 @@ for (const file of artifacts) {
8586 ContentType : contentTypeForExt [ path . extname ( file ) ] ,
8687 ContentEncoding : 'br' ,
8788 ContentLength : compressedFileContent . byteLength ,
88- CacheControl : `public, max-age=${ CACHE_MAX_AGE } , must-revalidate` ,
89+ // Assets stored under the commit hash never change after upload, so the
90+ // cache-control setting for them can be quite generous
91+ CacheControl : `public, max-age=${ IMMUTABLE_CACHE_MAX_AGE } , immutable` ,
8992 } ) ;
9093
9194 console . log ( 'Successfully uploaded %s (ETag: %s)' , file , res . ETag ) ;
0 commit comments