You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A good place to read about how this works is ngx_http_do_file_cache_read and ngx_http_file_cache_reopen. I'll summarize it here for you.
When nginx gets a file from the cache using ngx_http_file_cache_open (for a GET or a single-key PURGE), it has some hash function H and it calculates H(cachekey) and uses that to look up a file. That file might say "this resource varies on these headers". If it does say that, it compares the header values stored in the file to the header values in the request. If they do not match, it looks up the file at H(H(cachekey)+values of headers) instead. Or something like that.
In your scenario, if you want to purge both files, you should purge with curl headers first, then purge with your web browser's headers. If you do it in the opposite order, after purging the file created in step 1, the file created in step 2 will not be able to be found by ngx_http_file_cache_open, so you will get a 404, but the content will still be in the cache. At this point if you GET with your web browser, then GET with curl, curl will be served the cached content you tried to purge.
I have a scenario where the upstream server (in this case Django) may set a few vary headers. I do ignore Set-Cookie in the Nginx configuration.
/path/
from a web browser -> creates a file in the cache directory./path/
with curl -X GET from a command line on the webserver -> creates another file in the cache directory.I assume this is because of different Accept-Encoding's and I understand the reasoning.
Now, when I issue
curl -X PURGE http://localhost/path/
only the cached file from (2) is deleted.Is there a way to tell the module to consider only the cache key, no other headers, when determining which cached files to delete?
The text was updated successfully, but these errors were encountered: