From d9b0e08ea2a3cb87f79f4507ece3f4bc147d5380 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 12 Jan 2023 16:20:37 +0000 Subject: [PATCH] Fix caching headers on Docker image --- config/nginx.conf | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index 2af6c30..f725346 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -2,9 +2,24 @@ server { listen 8080; server_name localhost; + root /app; + location / { - root /app; + # disable cache entriely by default (apart from Etag which is accurate enough) + add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + if_modified_since off; + expires off; + # also turn off last-modified since they are just the timestamps of the file in the docker image + # and may or may not bear any resemblance to when the resource changed + add_header Last-Modified ""; + try_files $uri /$uri /index.html; } + + # assets can be cached because they have hashed filenames + location /assets { + expires 1w; + add_header Cache-Control "public, no-transform"; + } }