From e998ec7c2d157fa39bb10427e90d808b6b0c91d5 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 24 Aug 2023 13:19:46 +0200 Subject: [PATCH] :bug: Fix cache issues on devevn nginx config --- docker/devenv/files/nginx.conf | 60 ++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/docker/devenv/files/nginx.conf b/docker/devenv/files/nginx.conf index ec9051d09..175f7f2cf 100644 --- a/docker/devenv/files/nginx.conf +++ b/docker/devenv/files/nginx.conf @@ -92,34 +92,13 @@ http { error_page 301 302 307 = @handle_redirect; } - location /internal/gfonts/css { - proxy_pass https://fonts.googleapis.com/css?$args; - proxy_hide_header Access-Control-Allow-Origin; - proxy_hide_header Cross-Origin-Resource-Policy; - proxy_hide_header Link; - proxy_hide_header Alt-Svc; - proxy_hide_header Cache-Control; - proxy_hide_header Expires; - - proxy_ignore_headers Set-Cookie Vary Cache-Control Expires; - - proxy_set_header User-Agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"; - proxy_set_header Host "fonts.googleapis.com"; - proxy_set_header Accept "*/*"; - - proxy_cache penpot; - - add_header Access-Control-Allow-Origin $http_origin; - add_header Cache-Control max-age=86400; - add_header X-Cache-Status $upstream_cache_status; - } - location /internal/assets { internal; alias /home/penpot/penpot/backend/assets; add_header x-internal-redirect "$upstream_http_x_accel_redirect"; } + # On production, this is controlled by ELB location /api/export { proxy_pass http://127.0.0.1:6061; } @@ -192,17 +171,48 @@ http { add_header X-Cache-Status $upstream_cache_status; } + location ~ ^/internal/gfonts/css { + proxy_pass https://fonts.googleapis.com/css?$args; + proxy_hide_header Access-Control-Allow-Origin; + proxy_hide_header Cross-Origin-Resource-Policy; + proxy_hide_header Link; + proxy_hide_header Alt-Svc; + proxy_hide_header Cache-Control; + proxy_hide_header Expires; + + proxy_ignore_headers Set-Cookie Vary Cache-Control Expires; + + proxy_set_header User-Agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"; + proxy_set_header Host "fonts.googleapis.com"; + proxy_set_header Accept "*/*"; + + proxy_cache penpot; + + add_header Access-Control-Allow-Origin $http_origin; + add_header Cache-Control max-age=86400; + add_header X-Cache-Status $upstream_cache_status; + } + + location ~ ^/js/config.js$ { + add_header Cache-Control "no-store, no-cache, max-age=0" always; + } + + location ~* \.(js|css|jpg|svg|png)$ { + # We set no cache only on devenv + add_header Cache-Control "no-store, no-cache, max-age=0" always; + # add_header Cache-Control "max-age=604800" always; # 7 days + } + location ~ ^/(/|css|fonts|images|js|wasm) { } - + location ~ ^/[^/]+/(.*)$ { return 301 " /404"; } add_header Last-Modified $date_gmt; - add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + add_header Cache-Control "no-store, no-cache, max-age=0" always; if_modified_since off; - expires off; try_files $uri /index.html$is_args$args =404; } }