我想为我的(Pylons)上游服务器的某些响应指定没有caching,以避免用户在注销后能够访问caching的内容。 为此,我按照nginx文档返回一个无caching头。 具体来说,这一个:
Cache-Control: max-age=0, must-revalidate, no-cache, no-store
Nginx返回一个caching的响应,无视我的头。 任何想法为什么?
谢谢,瑞克
nginx changelog为0.7.48提到了一个bugfix:
漏洞修复:现在,nginx考虑了后端响应中的“X-Accel-Expires”,“Expires”和“Cache-Control”标题行。
也许你使用proxy_ignore_headers:
proxy_ignore_headers "Cache-Control" "Expires";
注释或删除此string。
不,根本不使用这个指令。 这是configuration:
worker_processes 1; error_log logs/error.log; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; access_log logs/access.log; sendfile on; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; } server { listen 80; server_name site.com; server_name_in_redirect off; client_max_body_size 11M; location ^~ /members/ { proxy_pass http://127.0.0.1:5010; } location ^~ /login/ { rewrite ^ https://$host$request_uri permanent; } error_page 404 /error/404.html; error_page 500 502 503 504 /error/500.html; }
我将使用“私人”选项进行caching控制,另一方面,除非您指定了proxy_cacheconfiguration选项,否则nginx不会caching,您确定caching是在nginx中完成的吗?