我正在尝试无条件地缓存一个既不提供Expires也不提供Cache-Control头的上游服务器。我没有管理...
设定:
proxy_cache_path /tmp/nginx keys_zone=motus_cache:2m max_size=1g
inactive=60m use_temp_path=off;
server {
listen 8000 default_server;
listen [::]:8000 default_server;
server_name _;
location / {
proxy_cache motus_cache;
proxy_buffering on;
proxy_pass https://motus.org;
proxy_ssl_name "motus.org";
proxy_ssl_server_name on;
proxy_ignore_headers "Set-Cookie" "Expires" "Cache-Control";
proxy_hide_header Set-Cookie;
proxy_hide_header X-Powered-By;
}
}
样品请求:
curl -o /dev/null 'http://localhost:8000/data/binary/tagVisits'
(大约需要7秒)
来自上游服务器的标头:
< HTTP/1.1 200 200
< Content-Type: application/octet-stream
< Server: Microsoft-IIS/8.5
< Set-Cookie: JSESSIONID=FE61DA4E7BD4996C09FB2B6D5E40D8CF; Path=/; Secure; HttpOnly
< X-Powered-By: ASP.NET
< Date: Mon, 10 Oct 2022 20:12:18 GMT
< Content-Length: 2779146
1条答案
按热度按时间ev7lccsx1#
找到了答案:我缺少proxy_cache_valid标头,例如: