Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
24
Help us understand the problem. What is going on with this article?

More than 5 years have passed since last update.

@osamu1203

Nginxで特定ページのキャッシュクリアする

1.ファイル内に書かれているKEYを元に検索し、削除する

find /var/cache/nginx/example.com -type f -exec grep -l "KEY: http://example.com/$" {} \; | xargs rm -f

この方法であれば、正規表現を使って削除対象を柔軟に指定できます。

例えばhttp://example.com/aaaa/ディレクトリ以下を削除したい場合は

find /var/cache/nginx/example.com -type f -exec grep -l "KEY: http://example.com/aaaa/.*$" {} \; | xargs rm -f

とすれば削除できます。

2.URLからファイルパスを特定し、削除する

echo -n "http://example.com/" | md5sum | awk '{print "/var/cache/nginx/example.com/"substr($1,length($1),1)"/"substr($1,length($1)-2,2)"/"$1}' | xargs rm -f

こちらのページが大変役立ちました。
http://server-setting.info/centos/nginx-cache-remove2.html

24
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
24
Help us understand the problem. What is going on with this article?