如何解决 Google 页面速度:"expiration not specified"
How to solve Google Page Speed: "expiration not specified"
使用 GooglePageSpeed 分析在线商店 (Shopware) 会导致每张图片上有许多 "expiration not specified" 行。
我想知道是因为网络服务器 (nginx) 添加了 Last-Modified-时间戳和 ETAG headers对所有图像的响应,导致对第二个请求的预期 304 响应。
ETAG/LastModified Google Page Speed 不支持吗?
我会提供nginx-configuration的适当部分:
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/ 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。将两者减少到一个语句解决了我们的问题
使用 GooglePageSpeed 分析在线商店 (Shopware) 会导致每张图片上有许多 "expiration not specified" 行。
我想知道是因为网络服务器 (nginx) 添加了 Last-Modified-时间戳和 ETAG headers对所有图像的响应,导致对第二个请求的预期 304 响应。
ETAG/LastModified Google Page Speed 不支持吗?
我会提供nginx-configuration的适当部分:
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/ 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。将两者减少到一个语句解决了我们的问题