Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fmbiete
Copy link

@fmbiete fmbiete commented Jun 5, 2015

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 😉

Francisco Miguel Biete added 2 commits June 3, 2015 13:58
This option can be slow if a lot of content is cached, or if the
storage used for the cache is slow. But you really should be using
RAM as your cache storage.

Signed-off-by: Francisco Miguel Biete <[email protected]>
<[email protected]>
Put an '*' at the end of your purge cache URL.
e.g:
    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.

Signed-off-by: Francisco Miguel Biete <[email protected]>
<[email protected]>
@hpatoio
Copy link

hpatoio commented Jun 6, 2015

This might solve #24

@rfnx
Copy link

rfnx commented Oct 13, 2015

@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
Copy link

hpatoio commented Oct 13, 2015

yes please @PiotrSikora I also need this !

@rfnx
Copy link

rfnx commented Oct 19, 2015

@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.

@rfnx rfnx mentioned this pull request Nov 10, 2015
@PiotrSikora
Copy link
Contributor

@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
Copy link

rfnx commented Nov 28, 2015

@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
Copy link
Author

fmbiete commented Dec 20, 2015

@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...

denji pushed a commit to nginx-modules/ngx_cache_purge that referenced this pull request Aug 3, 2016
This option can be slow if a lot of content is cached, or if the
storage used for the cache is slow. But you really should be using
RAM as your cache storage.

Signed-off-by: Francisco Miguel Biete <[email protected]>
Signed-off-by: Francisco Miguel Biete <[email protected]>

Resolved FRiCKLE#33
Resolved FRiCKLE#35
denji pushed a commit to nginx-modules/ngx_cache_purge that referenced this pull request Aug 3, 2016
Put an '*' at the end of your purge cache URL.
e.g:
    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.

Signed-off-by: Francisco Miguel Biete <[email protected]>
Signed-off-by: Francisco Miguel Biete <[email protected]>

Resolved FRiCKLE#33
Resolved FRiCKLE#35
@linxiaobai
Copy link

linxiaobai commented Jul 26, 2017

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants