Nginx – how to delete single nginx cache file

cachenginx

when access http://example.com/ its blank but working good with http://example.com/index.php
i need to delete nginx cache file for http://example.com/ how to do it?
Here my nginx cache conf.

    fastcgi_cache_path  /backup/cache levels=1:2 keys_zone=my-cache:1000m inactive=1000m;
    fastcgi_temp_path /backup/cache/tmp 1 2;
    fastcgi_cache_key "$scheme://$host$request_uri";

How to get the cache file name in /backup/cache folder?

Best Answer

one method, for example, but quite flexible an versatile

add this line to nginx.conf ...

proxy_cache_bypass $http_x_update;

... and you can anytime update any uri in cache with simple http request with "magic" header. for example

curl -s -o /dev/null  -H "X-Update: 1" mydomain.com

or

curl -s -o /dev/null  -H "X-Update: 1" mydomain.com/some/long/url/

for the security and satisfaction of paranoia :D you can change header name to any blablabla, for example

proxy_cache_bypass $http_x_gangnamstyle;
#proxy_cache_bypass $http_x_mycatsnickname;
#proxy_cache_bypass $http_x_b2ca678b4c936f905fb82f2733f5297f;

and

curl -s -o /dev/null  -H "X-GangnamStyle: 1" mydomain.com
curl -s -o /dev/null  -H "X-mycatsnickname: 1" mydomain.com
curl -s -o /dev/null  -H "X-b2ca678b4c936f905fb82f2733f5297f: 1" mydomain.com