我相信我的Nginx服务器上的缓存设置正确,但在检查firebug时在标题上我看到'Cache-Control:max-age = 0'。
我假设这意味着缓存无法正常工作。有什么想法吗?
编辑29/10/15: 服务器设置为智能静态文件处理,也可以通过nginx直接截取静态文件。以下是当前使用的附加指令。
# BEGIN W3TC Minify cache
location ~ /wp-content/cache/minify.*\.js$ {
types {}
default_type application/x-javascript;
add_header Vary "Accept-Encoding";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
expires 30d;
}
location ~ /wp-content/cache/minify.*\.css$ {
types {}
default_type text/css;
add_header Vary "Accept-Encoding";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
expires 30d;
}
location ~ /wp-content/cache/minify.*js\.gzip$ {
gzip off;
types {}
default_type application/x-javascript;
add_header Vary "Accept-Encoding";
add_header Content-Encoding gzip;
}
location ~ /wp-content/cache/minify.*css\.gzip$ {
gzip off;
types {}
default_type text/css;
add_header Vary "Accept-Encoding";
add_header Content-Encoding gzip;
}
# END W3TC Minify cache
# BEGIN W3TC Minify core
rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content /plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
set $w3tc_enc .gzip;
}
if (-f $request_filename$w3tc_enc) {
rewrite (.*) $1$w3tc_enc break;
}
rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins /w3-total-cache/pub/minify.php?test_file=$1 last;
rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins /w3-total-cache/pub/minify.php?file=$1 last;
# END W3TC Minify core
location ~* \.(js|css|svg|png|jpg|jpeg|gif|ico)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
log_not_found off;
access_log off;
}