Doing a mass purge of the cache using a wildcard

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Doing a mass purge of the cache using a wildcard

Jordan Keith
We 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?
2). Is there some other way I can accomplish a mass purge here?

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Doing a mass purge of the cache using a wildcard

Maxim Dounin
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/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx