我试图使用nginx fastcgi_cache来从我的网站服务一些页面,它工作正常,但我发现会话被复制到所有的用户,因为Set-Cookie被caching在响应中。
我已经尝试了几种解决scheme,但我不想在这些页面中禁用Cookie,只从caching中提供服务时忽略它们。 有没有办法做到这一点? 我考虑搬到清漆,但我有几个网站在同一台服务器,我想避免它。
我也试过这个 ,但没有成功
fastcgi_cache_path /etc/nginx/cache/iteramos levels=1:2 keys_zone=ITERAMOS:120m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; set $supercache_uri $request_uri; set $no_cache 1; #set no cache to 0 (do cache) if we are in listing pages if ($supercache_uri ~ ^/(preguntas|etiquetada|etiquetas)$) { set $no_cache 0; set $supercache_uri ''; } if ($supercache_uri = /) { set $no_cache 0; set $supercache_uri ''; } if ($supercache_uri ~ ^/?page= ) { set $no_cache 0; set $supercache_uri ''; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie"; fastcgi_cache ITERAMOS; fastcgi_cache_valid 200 60m; #this header adds a hit / bypass / miss header fastcgi_cache_use_stale error timeout; add_header X-Cache $upstream_cache_status; fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; }
提前致谢
尝试使用fastcgi_hide_header :
fastcgi_hide_header "Set-Cookie";
当请求到达caching时,这将隐藏所有的cookie。 官方文档