Skip to content

Commit 0ed8945

Browse files
committed
update cache control static file
1 parent 5d745d7 commit 0ed8945

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nginx.conf.sample

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
##
2525
## fastcgi_param MAGE_MODE $MAGE_MODE;
2626
##
27-
## In production mode, you should uncomment the 'expires' directive in the /static/ location block
27+
## In production mode, you should uncomment the 'add_header Cache-Control "public, max-age=31536000, immutable"' directive in the /static/ location block
2828

2929
# Modules can be loaded only at the very beginning of the Nginx config file, please move the line below to the main config file
3030
# load_module /etc/nginx/modules/ngx_http_image_filter_module.so;
@@ -105,17 +105,16 @@ location /pub/ {
105105

106106
location /static/ {
107107
# Uncomment the following line in production mode
108-
# expires max;
108+
# add_header Cache-Control "public, max-age=31536000, immutable";
109109

110110
# Remove signature of the static files that is used to overcome the browser cache
111111
location ~ ^/static/version\d*/ {
112112
rewrite ^/static/version\d*/(.*)$ /static/$1 last;
113113
}
114114

115115
location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2|html|json|webmanifest)$ {
116-
add_header Cache-Control "public";
116+
add_header Cache-Control "public, max-age=31536000, immutable";
117117
add_header X-Frame-Options "SAMEORIGIN";
118-
expires +1y;
119118

120119
if (!-f $request_filename) {
121120
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
@@ -167,9 +166,8 @@ location /media/ {
167166
}
168167

169168
location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2)$ {
170-
add_header Cache-Control "public";
169+
add_header Cache-Control "public, max-age=31536000, immutable";
171170
add_header X-Frame-Options "SAMEORIGIN";
172-
expires +1y;
173171
try_files $uri $uri/ /get.php$is_args$args;
174172
}
175173
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {

0 commit comments

Comments
 (0)