FRiCKLE / ngx_cache_purge

nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.
http://labs.frickle.com/nginx_ngx_cache_purge/
Other
1.06k stars 311 forks source link

Same location syntax doesn't work with $request_method in cache key #8

Closed Daniel15 closed 10 years ago

Daniel15 commented 11 years ago

The Nginx wiki suggests to have $request_method in the cache key:

Be advised that a HEAD request can cause an empty response to be cached & later be distributed to GET requests, avoid this by having $request_method in the cache key. Including the $scheme for the same reason may be beneficial to avoid serving up pages with insecure content to HTTPS visitors (or vice-versa).

However, this breaks the same location syntax, as it'd be looking for the incorrect cache key (with PURGE as the scheme instead of GET). I'd love to use the same location syntax, but I'm scared to remove $request_method from my cache key, knowing that a HEAD request hitting an uncached page will cache a blank page.

runningman84 commented 10 years ago

This suggestion seems to be outdated, nginx always does a GET request to backend servers in order to fill the cache. You can safely store remove the request_method from your cache key in my opinion.

PiotrSikora commented 10 years ago

The advice from the wiki is incorrect, like @runningman84 said, nginx always changes HEAD to GET in cacheable locations.

Daniel15 commented 10 years ago

I encountered this problem when I raised the issue (10 months ago) as I was encountering blank page loads and changing the cache key resolved it. Which Nginx version was this fixed in?

websitesca commented 5 years ago

Just wanted to say here that this caused me a lot of searching - I used this: fastcgi_cache_key "$scheme$request_method$host$request_uri"; Which cause mysterious 403 Not Allowed errors. Removing $request_method fixes the problem