このページの翻訳:
- 日本語 (ja)
- English (en)
最近の更新
- 31 CentOS5 TLS1.2 created
- 2024.04.12 MySQL BIT Field created
- 04 ↷ 50_dialy:2024:04:04 から 50_dialy:2024:04:05 へページを名称変更しました。
最近の更新
文書の過去の版を表示しています。
nginxにはキャッシュ機能としてプロキシキャッシュとFastCGIキャッシュがある。
fastcgi_cache_pathとfastcgi_cache_keyは、httpディレクティブに記述
http { fastcgi_cache_path /config/cache/nginx levels=1:2 keys_zone=cache-zone:30m max_size=512M inactive=600m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; . . . .
こちらはlocationディレクティブに記述
location ~ \.php$ {
fastcgi_read_timeout 300; fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; ### 以下の設定を追加 ### set $do_not_cache 0;
# -- POST or HEAD ? if ($request_method != "GET") { set $do_not_cache 1; } # -- Login or Comment or Post Editting ? if ($http_cookie ~ ^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$) { set $do_not_cache 1; } fastcgi_cache cache-zone; fastcgi_cache_valid 200 60m; add_header X-F-Cache $upstream_cache_status;
}
</code>
「X-F-Cache」で確認できる。
設定の下記部分
add_header X-F-Cache $upstream_cache_status;
# curl -D - -s -o /dev/null http://localhost/info.php HTTP/1.1 200 OK Server: nginx/1.18.0 Date: Sat, 01 May 2021 13:52:56 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/7.4.15 X-F-Cache: MISS
# curl -D - -s -o /dev/null http://localhost/info.php HTTP/1.1 200 OK Server: nginx/1.18.0 Date: Sat, 01 May 2021 13:52:58 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/7.4.15 X-F-Cache: HIT