Doing a mass purge of the cache using a wildcard

Maxim Dounin mdounin at mdounin.ru
Mon Oct 7 12:38:29 UTC 2019


Hello!

On Fri, Oct 04, 2019 at 12:25:22PM -0500, Jordan Keith wrote:

> We are using nginx plus.

Just to make sure you know: contacting support might be a 
better/faster option if you are using nginx-plus.

> We have caching configured for a few endpoints, one which is similar to the following: 
> 
> document/{id}/report 
> 
> I would like to purge all items cached under that endpoint, but executing a purge request like the following does not purge anything: 
> 
> document/*/report 
> 
> We have other endpoints where mass purges work fine, but they have the * at the end of the URL instead of the middle. 
> 
> So I have 2 questions: 
> 
> 1). Does nginx only support wildcards at the end of the URL for cache-purging purposes? 

Quoting http://nginx.org/r/proxy_cache_purge:

: If the cache key of a purge request ends with an asterisk (“*”), all cache
: entries matching the wildcard key will be removed from the cache.

Note "ends with" - only wildcards at the end of the cache key are 
supported.  This doesn't mean "at the end of the URL" though, as 
cache keys can be arbitrary configured (see 
http://nginx.org/r/proxy_cache_key).

> 2). Is there some other way I can accomplish a mass purge here? 

If you want to purge resources like this on a regular basis, 
re-structuring your proxy_cache_key might be an option.  For 
example, you may split "document/{id}/report" into "document/{id}" 
and "/report", and put "/report" into the cache key first.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list