diff --git a/nginx.conf.sample b/nginx.conf.sample index 9d80b478efec1..85e2fb66dec94 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; @@ -110,7 +110,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*/ { @@ -118,9 +118,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; 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"