LoginSignup
4
2

More than 5 years have passed since last update.

nginxのproxy_cache_keyのデフォルト

Posted at

ngx_cache_purgeモジュール使ってキャッシュ削除しようとしたけどproxy_cache_keyが設定されてなくて泣いたのでメモ
公式ドキュメントが当てにならないというか、嘘はついてないけどホントの事も書いてないw

By default, the directive’s value is close to the string
proxy_cache_key $scheme$proxy_host$uri$is_args$args;

となってるので、

location ~* /purge_cache(/.*) {
    proxy_cache_purge THE_CACHE "$scheme$proxy_host$1$is_args$args";
}

と書いてみたけど動かない(;;
$proxy_hostはログ書き出しのように実際にプロキシが充てられてからは使えるっぽいけど、こういう場合には使えないみたい...
なので、バックエンドを

upstream cache_cluster {
    server 127.0.0.1;
}

とかしてる場合、

location ~* /purge_cache(/.*) {
    proxy_cache_purge THE_CACHE "http://cache_cluster$1$is_args$args";
}

という様にバックエンドの名前をちゃんと書いてやらないと反応してくれない。

4
2
0

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
4
2