这是相关的nginx配置片段:
location ^~ /static/ {
expires max;
rewrite ^/static/[^/]+/(.*)$ /$1 last;
}
重新加载nginx之后,出于某种原因没有Expires标头的迹象:
$ curl -i http://monda.hu/static/1/blog/wp-content/icomoon/style.css
HTTP/1.1 200 OK
Server: nginx/1.4.1 (Ubuntu)
Date: Sat, 21 Dec 2013 22:55:46 GMT
Content-Type: text/css
Content-Length: 1783
Last-Modified: Tue, 16 Jul 2013 21:03:00 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "51e5b504-6f7"
Accept-Ranges: bytes
(这里的想法是在相关资源发生变化时递增URL中的数字版本值。请不要告诉我expires max
是一种不好的做法。我认为这是一个品味和优先事项。)
除上述内容外,相关服务器部分还有以下位置块:
location ~ \.php$ { ... }
location / { ... }
location ~ /\. { ... }
location ^~ /mydbadmin/ { ... }
location @php { ... } # this one is not even referenced