FRiCKLE / ngx_cache_purge

nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.
http://labs.frickle.com/nginx_ngx_cache_purge/
Other
1.06k stars 311 forks source link

Feature: Partial keys (includes pull #33) #35

Open fmbiete opened 9 years ago

fmbiete commented 9 years ago

This pull includes #33, but each one is only a commit so it should be quite easy to cherry-pick. Sorry about that.

Adds support to partial keys.

When using complexes key_cache or when you need to purge the cache of more than one page, you will miss the option of using wildcards.

Here, we support willcards in the URI:

Example of use:

Put an '*' at the end of your purge cache URL.

proxy_cache_key $scheme$host$uri$is_args$args$cookie_JSESSIONID;

curl -X PURGE https://example.com/pass*

This will remove every cached page whose key cache starting with:

httpsexample.com/pass*

Be careful not passing any value for the values after the $uri, or put it at the end of your cache key.

As in the other pull request, feel free to improve or suggest improvements :wink:

hpatoio commented 9 years ago

This might solve #24

rfnx commented 9 years ago

@fmbiete Thanks for your work, this patch is exactly what I needed ! It's one of the most interesting features of nginx plus cache IMO.

@PiotrSikora Can we have a word from the developer on this please ? Because according to https://github.com/FRiCKLE/ngx_cache_purge/blob/master/TODO.md , prefixed purges are "impossible". It would be amazing to have this officially included in the extension :)

hpatoio commented 9 years ago

yes please @PiotrSikora I also need this !

rfnx commented 9 years ago

@fmbiete I just compiled your fork and it does not work with nginx 1.9.5, I had crashes when I tried to make a simple purge (single page). I had no time to test more but I'll do it maybe later.

PiotrSikora commented 8 years ago

@fmbiete thanks for your work, but this is far from useable (it doesn't invalidate items in cache, it doesn't look that it would work with AIO, and most importantly, it would block worker process for the time it needs to walk all the directories and read the files - which in pessimistic case can be as long as 1s for cache with as little as 100 files).

rfnx commented 8 years ago

@PiotrSikora Hello ! When you say it's impossible with the current implementation, can you explain why ? It could help us if we want to improve this plugin.

fmbiete commented 8 years ago

@PiotrSikora

It doesn't invalidate items in cache

Since the file corresponding to the cached item will not exist anymore nginx will invalidate the item. It's far from perfect, and I would love to find an alternative.

it would block worker process

Of course, it will block the thread of the worker running the request, not the whole worker.

for the time it needs to walk all the directories and read the files

This should be used with the cache folder in RAM disks, and there this time will be almost zero. I believe it's not really intelligent to put the cache in disk. Your web content should already be on disk, so disk cache will give you 0 improvements...

linxiaobai commented 7 years ago

It's very hard to purge some pic that has some relationship, like a.jpg , a/480x360.jpg, a/20x60.jpg and more. We can only purge every pic one by one.

Please inform me if one day can be purge by pattern match.Thanks!

hilyjiang commented 6 years ago

This cause nginx worker exited when config as separate location, event purge without '*'. Test under v1.12.2