nginx proxy_hide_header仍然caching头文件

我使用nginx和proxy_cache来caching一些页面,我已经设置了一个单独的刷新位置块来刷新一个特定的caching条目。 我已经testing了这一点,它为刷新工作正常。

但是它也caching了set-cookie头(我使用的框架,Symfony,即使没有login也总是为新用户创build一个新的会话cookie)。 我search了一下,显然proxy_hide_header应该帮助我,但它只隐藏返回给客户端的最终响应头,头仍然被caching。 我也尝试了其他标题,并有相同的结果。 我也尝试使用headers_more_module(more_clear_headers),但这也没有帮助。 有没有人知道这里有什么问题,或有别的我想要做的? 我正在使用nginx 1.11.2,这是configuration:

location ~ /refresh(/.*) { allow 127.0.0.1; deny all; rewrite ^/refresh?(/.*)$ $1 break; proxy_hide_header "Set-Cookie"; proxy_ignore_headers "Set-Cookie" "Vary"; proxy_cache FOS_CACHE; proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_cache_key $uri$is_args$args; proxy_cache_valid 200 1m; proxy_cache_bypass 1; access_log /var/log/nginx/cache_refresh.log cache_info; } 

谢谢

以下是一个想法。 它解决你的问题吗?

 if ($http_cookie ~ "*"){ set $no_cache 1; } proxy_cache_bypass $no_cache;