Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

eversense
家族を幸せにすることで、笑顔溢れる社会をつくる。
https://eversense.co.jp/
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした