From 0ed8945b84ba50efb33f56d58065ad6fbd4fef26 Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 16 Dec 2024 16:59:35 +0000 Subject: [PATCH 1/2] update cache control static file --- nginx.conf.sample | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nginx.conf.sample b/nginx.conf.sample index cc1d52e1d9284..5647ead6c0390 100644 --- a/nginx.conf.sample +++ b/nginx.conf.sample @@ -24,7 +24,7 @@ ## ## fastcgi_param MAGE_MODE $MAGE_MODE; ## -## In production mode, you should uncomment the 'expires' directive in the /static/ location block +## In production mode, you should uncomment the 'add_header Cache-Control "public, max-age=31536000, immutable"' directive in the /static/ location block # Modules can be loaded only at the very beginning of the Nginx config file, please move the line below to the main config file # load_module /etc/nginx/modules/ngx_http_image_filter_module.so; @@ -105,7 +105,7 @@ location /pub/ { location /static/ { # Uncomment the following line in production mode - # expires max; + # add_header Cache-Control "public, max-age=31536000, immutable"; # Remove signature of the static files that is used to overcome the browser cache location ~ ^/static/version\d*/ { @@ -113,9 +113,8 @@ location /static/ { } location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2|html|json|webmanifest)$ { - add_header Cache-Control "public"; + add_header Cache-Control "public, max-age=31536000, immutable"; add_header X-Frame-Options "SAMEORIGIN"; - expires +1y; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; @@ -167,9 +166,8 @@ location /media/ { } location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2)$ { - add_header Cache-Control "public"; + add_header Cache-Control "public, max-age=31536000, immutable"; add_header X-Frame-Options "SAMEORIGIN"; - expires +1y; try_files $uri $uri/ /get.php$is_args$args; } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { From 9ef1e35a7a8c252be1b93e71003d1d04d082af0e Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 23 Dec 2024 02:13:47 +0000 Subject: [PATCH 2/2] update code --- nginx.conf.sample | 3 ++- pub/static/.htaccess | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nginx.conf.sample b/nginx.conf.sample index 5647ead6c0390..0ab215065f9e5 100644 --- a/nginx.conf.sample +++ b/nginx.conf.sample @@ -166,8 +166,9 @@ location /media/ { } location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2)$ { - add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; + expires +1y; try_files $uri $uri/ /get.php$is_args$args; } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { diff --git a/pub/static/.htaccess b/pub/static/.htaccess index 1cd3fef200683..77d4a94d9cee4 100644 --- a/pub/static/.htaccess +++ b/pub/static/.htaccess @@ -75,7 +75,7 @@ AddType application/xml xml - Header append Cache-Control public + Header append Cache-Control "public, immutable"