workers-site: add cache headers to resource files [staging]

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-05-19 21:48:46 +05:30
parent b466da9e52
commit 6f2e804ec4
1 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,10 @@ async function getPageFromKV(event: FetchEvent): Promise<Response> {
response.headers.set('Referrer-Policy', 'no-referrer-when-downgrade')
response.headers.set('Content-Security-Policy', CSP_POLICY)
response.headers.set('Permissions-Policy', PERMISSIONS_POLICY)
const url = event.request.url;
if (url.endsWith("css") || url.endsWith("js") || url.endsWith("ttf")) {
response.headers.set('Cache-Control', 'public, max-age=31536000');
}
return response
} catch (e) {
try {