Open fmbiete opened 9 years ago
This is indeed good addition! We currently just rm -fr the cache directory...
This feature is interesting but I don understand the setup:
With these conf
http {
proxy_cache_path /tmp/cache keys_zone=tmpcache:10m;
server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_cache tmpcache;
proxy_cache_key $uri$is_args$args;
proxy_cache_purge PURGE purge_all from 127.0.0.1;
}
}
}
Which URL you have to call to purge the whole cache ?
With that config you should use:
curl -X PURGE http://yourserver/
You can check the examples in the t/proxy3.t file
So is the very same I should use to purge the homepage right ?
IMHO you should work in another way (didn't check the conf but I hope the idea is clear)
http {
proxy_cache_path /tmp/cache keys_zone=tmpcache:10m;
server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_cache tmpcache;
proxy_cache_key $uri$is_args$args;
proxy_cache_purge PURGE from 127.0.0.1;
}
server {
location = /location_it_doesnt_exist_on_my_site {
proxy_pass http://127.0.0.1:8000;
proxy_cache tmpcache;
proxy_cache_key $uri$is_args$args;
proxy_cache_purge PURGE purge_all from 127.0.0.1;
}
}
}
So to purge one of you application URL use
curl -X PURGE http://yourserver/whatever/application/url.html
to purge all the cache
curl -X PURGE http://yourserver/location_it_doesnt_exist_on_my_site
Does it make sense ?
Of course, a "real" configuration should look like your example: existing location to purge individual pages, alternative non-existent location to purge_all, and another to purge using wildcards.
The code accepts both of them; since it's a matter of configuration it is up the user to choose what they prefer to do.
I think a separated directory option fastcgi_cache_purge_all
would be cleaner to use:
* **syntax**: `fastcgi_cache_purge_all zone_name`
* **default**: `none`
* **context**: `location`
usage:
server {
location = /purge_all {
proxy_cache_purge_all tmpcache;
}
}
This adds an optional option (purge_all) to the purge_cache configuration, so if this special location is called the whole cache will be cleared.
I'm new to nginx development, and the documentation is zero, so I'm sure there is a better solution. If you can improve it, suggestions/reviews are very welcomed.