FRiCKLE/ngx_cache_purge

purge and vary header

dbu opened this issue · 3 comments

dbu commented

does purge with this plugin have the same semantics as with varnish? does it invalidate all variants of a document, or only the one matching the purge request? say i have a URL /path and one client requested it with an Accept-Encoding: json, and the other with Accept-Encoding: xml. my web application returns json first and then xml, sending the Vary: Accept-Encoding header.

in varnish, purge will remove all cache entries for this url, even though there is more than one. what will nginx with this plugin do? would i need to purge with different Accept-Encoding set?

dbu commented

ping

No, it has the same semantics as nginx, which means that caching is based on keys and not URLs and that only a single representation (read: single cache key) is removed from cache during cache purge request.

Hello,

Nginx will save response to different cache files when Vary: Accept-Encoding is set. That is, one will be uncompressed, other compressed. This module will delete only one version of the file, making it partially usable. This was added in nginx changeset 60fde1bc7236:

http://mailman.nginx.org/pipermail/nginx-devel/2014-October.txt

Changes with nginx 1.7.7 28 Oct 2014

*) Change: now nginx takes into account the "Vary" header line in a
   backend response while caching.