我使用的是 Debian 8、Nginx 1.10、服务器 Apache2。我的 Nginx 配置是:
proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m inactive=60m;
proxy_cache_key "$scheme$request_method$host$request_uri";
server {
....
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|css|js)$ {
proxy_cache my_zone;
expires 24h;
add_header Cache-Control "public";
proxy_pass http://*******.com;
proxy_cache_bypass $http_cache_control;
add_header X-Proxy-Cache $upstream_cache_status;
}
}
CURL 的结果是:
curl -X GET -I http://******/test.png
HTTP/1.1 200 OK
Server: nginx/1.10.3
Date: Sat, 22 Jul 2017 01:55:56 GMT
Content-Type: image/png
Content-Length: 28847
Connection: keep-alive
Last-Modified: Fri, 21 Jul 2017 06:10:10 GMT
Vary: Accept-Encoding
Expires: Sun, 23 Jul 2017 01:55:56 GMT
Cache-Control: max-age=86400
Cache-Control: public
X-Proxy-Cache: MISS
Accept-Ranges: bytes
是否存在缺少的配置?
谢谢任何建议!