大网数据广告活动
服务器运维问答

how to delete single nginx cache file?

· 52CE 我爱测

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 level…

问题原文

原帖链接 · imastar · CC BY-SA 3.0

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?

社区高分解答

原帖链接 · cadmi · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-03-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。