使用GooglePageSpeed分析在线商店(Shopware)会导致许多“未指定有效期限”-每个图像上的行。
我想知道是因为Web服务器(nginx)在所有图像的响应中添加了Last-Modified -Timestamps和ETAG标头,导致第二个请求产生了预期的304-Response。
Google Page Speed不支持ETAG / LastModified吗?
我将提供nginx配置的适当部分:
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
## All static files will be served directly.
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|html|xml)$ {
## Defining rewrite rules
rewrite files/documents/.* /engine last;
rewrite backend/media/(.*) /media/$1 last;
expires 1w;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
# The directive enables or disables messages in error_log about files not found on disk.
log_not_found off;
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=3000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
## Fallback to shopware
## comment in if needed
#try_files $uri @shopware;
}
是否有任何错误或遗漏?
最终我们发现,vhost-config中还有另一个expire-statement。将两者简化为一个语句即可解决我们的问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句