26
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

##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

26
24
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?