とりあえず、ヘッダーにキャッシュステータスを出力させてみる。configファイルのserverブロック以下に下記の一行を追加。
add_header X-Cache $upstream_cache_status;
これでレスポンスヘッダにキャッシュ状態が表示されるようになります。
Nginx: Cache HIT’s not happening - Server Fault
proxy_ignore_headers Set-Cookie; だけだと
Set-Cookie: ヘッダがキャッシュされてしまう。
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
# important! Remember the special inheritance rules for proxy_set_header:
# http://nginx.org/ru/docs/http/ngx_http_proxy_module.html#proxy_set_header
proxy_set_header Cookie "";Leverage proxy caching with nginx by removing Set-Cookie header - Server Fault
キャッシュ削除
2. キャッシュの確認
以下は、当ブログ http://www.mk-mode.com/octopress のキャッシュの存在を確認する例。
# grep -lr "http://www.mk-mode.com/octopress/*" /var/cache/nginx/cache/ /var/cache/nginx/cache/f/ee/ea8c92983954d4e0e833580f04e61eef /var/cache/nginx/cache/c/9a/703db7ec8a20d23a018c99052a78b9achttps://www.mk-mode.com/octopress/2016/09/15/nginx-deleting-proxy-caches/
キャッシュファイルの中にURL文字列があるので検索、該当ファイルを削除する。