From 4ca2f5f3a310228b8065a8ecd9c178cf4819c15f Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 13 Apr 2024 12:53:12 +0200 Subject: [PATCH] docker: very aggressive CDN, media, css and js file caching on nginx site config --- docker/nginx/leftypol.conf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docker/nginx/leftypol.conf b/docker/nginx/leftypol.conf index 83f8b10a..b531e736 100644 --- a/docker/nginx/leftypol.conf +++ b/docker/nginx/leftypol.conf @@ -21,17 +21,16 @@ server { # Expire rules for static content # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { - expires 1M; - access_log off; log_not_found off; - add_header Cache-Control "public"; + # Public cache, never changes until max-age expires, max-age of 1 month, can still be served while being + # revalidated or if the server is erroring for 1 day. + add_header Cache-Control "public, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=86400"; } # CSS and Javascript location ~* \.(?:css|js)$ { - expires 1y; - access_log off; log_not_found off; - add_header Cache-Control "public"; + # Public cache, max-age of 1 year, can still be served while being revalidated or if the server is erroring for 1 day. + add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=86400, stale-if-error=86400"; } location ~* \.(html)$ {