###前提・実現したいこと
さくらVPS・CentOS6.5・wordpress・Apacheで運用していたブログをNginxに移行しました。リバースプロキシキャッシュとして利用するようにしたのですが、記事を更新してもキャッシュが削除されない状態です。
###ここに質問したいことを詳細に書いてください
Nginx Cache Controllerプラグインを使って、記事の投稿時、または、投稿後の編集にて記事を更新したときに自動でそのページのキャッシュを削除できるようにしたいです。
###発生している問題・エラーメッセージ
プラグインを導入・設定した後、記事を更新してもキャッシュが削除されていない。
/etc/nginx/conf.d/default.confの設定はこちらの解説(WordPress向けnginxの設定)を参考にしました。恥ずかしながら知識はなく、勉強しながらコードを学んでいます。
・プラグイン側で設定したキャッシュディレクトリ /var/cache/nginx/cache1 ・default.conf内のコード(重要かと思っている箇所の一部抽出です) proxy_cache_path /var/cache/nginx/cache1 levels=1 keys_zone=cache1:128m; proxy_cache cache1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; server { set $do_not_cache 0; if ($uri ~* "\.php$") { set $do_not_cache 1; } (-)set $proxy_cache_key "$scheme$proxy_host$request_uri"; (+)set $proxy_cache_key "$scheme://$proxy_host$request_uri"; if ($http_user_agent ~* "iPhone") { //set $do_not_cache 1; set $proxy_cache_key "iphone::$proxy_cache_key"; } if ($http_cookie ~ "(wordpress_logged_in_|comment_author_)(.*)") { //set $do_not_cache 1; set $proxy_cache_key "$2::$proxy_cache_key"; } location / { proxy_no_cache $do_not_cache; proxy_cache_bypass $do_not_cache; proxy_cache_key $proxy_cache_key; proxy_pass http://unix:/var/run/nginx.sock; } } server { listen unix:/var/run/nginx.sock; server_name 【IPアドレスを入れてます】; try_files $uri $uri/ /index.php; location / { root /var/www/html/wordpress; index index.php; if (-f $request_filename) { expires 30d; break; } if (!-e $request_filename) { rewrite ^.+?(/wp-.*) $1 last; rewrite ^.+?(/.*\.php)$ $1 last; rewrite ^ /index.php last; } } location ~ \.php$ { root /var/www/html/wordpress; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; ↓追加しました fastcgi_pass_header "X-Accel-Redirect"; fastcgi_pass_header "X-Accel-Buffering"; fastcgi_pass_header "X-Accel-Charset"; fastcgi_pass_header "X-Accel-Expires"; fastcgi_pass_header "X-Accel-Limit-Rate"; } // deny access to .htaccess files, if Apache's document root // concurs with nginx's one //location ~ /\.ht { // deny all; } } ・プラグイン側の設定 キャッシュ削除の有効化→YES キャッシュレベル→1 投稿公開時→表示中のページと単独投稿記事と単独固定ページ以外のキャッシュを削除。 ###試したこと (修正前) set $proxy_cache_key "$scheme$proxy_host$request_uri"; ↓ (修正後) set $proxy_cache_key "$scheme://$proxy_host$request_uri"; こちらも試してみました(変わりませんでした) set $proxy_cache_key "$scheme://$host$request_uri"; ###補足情報 記事の更新前に、(1)キャッシュを削除したい記事にアクセスしておく→(2)閉じる→(3)記事内容を変更し更新→(4)再度アクセス→(1)の情報のまま変わりません。ワードプレスはログアウトしているブラウザで確認しています。 わかりにくい説明かと思いますが、かれこれずっと改善できていません。お願いいたします。
あなたの回答
tips
プレビュー