Question about proxy_cache_key

Francis Daly francis at daoine.org
Thu Feb 16 12:41:04 UTC 2017


On Thu, Feb 16, 2017 at 01:08:35PM +0700, Dewangga Bachrul Alam wrote:

Hi there,

> proxy_cache_key "$uri$is_args$args";
> 
> location / {
>          proxy_ignore_headers Cache-Control Expires Set-Cookie;
>          rewrite (?<capt>.*) $capt?$args&view=$mobile break;
> }

> My question is, the URI
> https://subdomain.domain.tld/artikel/berita/a-pen-by-hair accessed
> from another browser (eg. Safari) and cache status was HIT, then I
> tried to invoke `PURGE` command from shell using cURL, it was failed
> and return cache_key not found

I do not know the "fix"; but I suspect that the *reason* is due to the
Vary header that is sent in the response.

If you know that "Vary" is not relevant in your case, then possibly
temporarily adding it to proxy_ignore_headers will let you see whether
that is related.

> The following argument "&view=desktop?" should be follow. Is there any
> hints to match the proxy_cache_key? So I can purge the cache anywhere
> and anytime?

I guess that the "view=desktop" part comes from your rewrite directive;
it may take more documentation-digging to find the actual cache key that
is used internally in nginx, so that the purge facility can work with it.

(Or possibly the ngx_cache_purge module could be updated to work
transparently with the current nginx cache key behaviour -- I do not
know whether that is possible.)

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list