Nginx proxy cache invalidation (purging content)
I wrote script which can purge your content directly from binary files in
proxy_cache_path. Everything what you have to do is set your
CACHE_DIR variable in script. Script will find your proxy cache key in binary files.
After this you will have options for purging this file.
This purge script was wrote in bash, so you need bash interpreter.
Example of setting nginx:
proxy_cache_path /tmp/cache keys_zone=tmpcache:10m;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_cache tmpcache;
proxy_cache_key $uri$is_args$args;
}
Download link: http://sourceforge.net/projects/nginxproxypurge/

Categories:
Tags:
Very useful! Thanks for the handy script.
Neat script, thanks.
Hi, I was trying to used your script bug couldn’t make it work. Always have error like this.
[root@nfs ~]# ./nginxCacheInvalidation.sh
Enter pattern of your file which you want to purge: js
I can’t find your pattern in you cache: js in file: /var/log/data/static_cache/0/73/b00d641b03c7ea798abebd7b4f2d1730
Hi I used this config:
proxy_cache_key $scheme://$host$request_uri;
proxy_cache_path /var/log/nginx/nginx-client-body levels=1:2 keys_zone=main:6200m inactive=1000m max_size=1000m;
When I run the scrip and type main.css or img1.png it says I found 1 key but it does not display. How can I make it work thanks.
Show me please your CACHE_DIR varible.
CACHE_DIR=/var/log/nginx/nginx-client-body
I try to search like index.js it shows some files but If I type only “js” no index It only say I found but no list.
Got it workin thanks a lot!!!
I more question I found out some cache can’t be located.
Enter pattern of your file which you want to purge: index.js
I can’t find your pattern in you cache: index.js in file: /var/wwwr/data/1/4a/409919e26e96959d75eb146471d064a1
There is some problem with 409919e26e96959d75eb146471d064a1 file, try it explore and try to find index.js in this file.
I found many index.js on that file when I try to look.
$.getScript(gbl_static_url+’js/registration/index.js’);