我正在从apache web服务器迁移网站,无法获得nginx标头过期工作。这是服务器块的一部分(在子域上测试):
server {
listen 80 default_server;
server_name br.mydomain.com;
server_name www.br.mydomain.com;
server_name ipv4.br.mydomain.com;
server_name localhost;
# Path for static files
root /usr/share/nginx/html;
#Specify a charset
charset utf-8;
# Custom 404 page
error_page 404 /404.html;
# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html|xml|json)$ {
expires -1;
# access_log logs/static.log;
}
# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}
# Favicon
location ~* \.ico$ {
expires 1w;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
}
# Media: images, video, audio, HTC, WebFonts
location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
expires 1M;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
}
location ~* \.(js|css)$ {
expires 60d;
add_header Pragma public;
add_header Cache-Control "public";
}
# CSS and Javascript
#location ~* \.(?:css|js)$ {
# expires 1y;
# access_log off;
# add_header Cache-Control "public";
#}
# opt-in to the future
add_header "X-UA-Compatible" "IE=Edge,chrome=1";
}
Nginx重新启动OK,没有错误消息,但它不会更改标头过期:
Cache-Control:max-age=604800
Connection:keep-alive
Date:Wed, 27 Nov 2013 22:07:55 GMT
Expires:Wed, 04 Dec 2013 22:07:55 GMT
Last-Modified:Mon, 18 Nov 2013 08:34:10 GMT
Server:nginx
X-Powered-By:PleskLin
这里可能出现什么问题并阻止设置过期时间?
谢谢!
更新:花了5个小时调试这个简单的事情我发现了问题:
更改nginx配置文件后重新加载nginx(/etc/init.d/nginx reload)是不够的 - 应该重新启动Plesk面板上的nginx服务(关闭/打开)。否则,将不会应用更改。