From 8c31a10d6ea6cbebcbb5c5f4f7c8b42352d424b6 Mon Sep 17 00:00:00 2001 From: Marco Iorio Date: Thu, 28 Apr 2022 08:55:29 +0200 Subject: [PATCH] Frontend: configure caching policy in nginx.conf --- frontend/nginx.conf.tmpl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/nginx.conf.tmpl b/frontend/nginx.conf.tmpl index a3dfd3c0a..459501472 100644 --- a/frontend/nginx.conf.tmpl +++ b/frontend/nginx.conf.tmpl @@ -6,11 +6,32 @@ server { root /usr/share/nginx/html; index index.html; try_files $uri ${SUBROUTE}/index.html; + + # Ensure that non-versioned resources are checked + # with upstream before using the cached version. + add_header Cache-Control 'no-cache must-revalidate'; + expires 0; + } + + location ~ ${SUBROUTE}/favicon.* { + root /usr/share/nginx/html; + + # Allow favicons to be cached, although for shorter periods. + add_header Cache-Control 'public'; + expires 1M; + } + + location ${SUBROUTE}/static { + root /usr/share/nginx/html; + + # Allow versioned resources to be cached freely, since a modification + # would also change the file name (i.e. they are immutable). + add_header Cache-Control 'immutable'; + expires 1y; } location /healthz { access_log off; return 200 "healthy\n"; } - }