1. 禁用 PHP 页面缓存
location ~ \.php$ {
fastcgi_pass php_wordpress1;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PHP_VALUE "open_basedir=/var/www/html:/tmp";
fastcgi_param HTTPS on;
fastcgi_param SERVER_PORT 443;
# 测试阶段注释掉缓存配置
# fastcgi_cache WORDPRESS;
# fastcgi_cache_valid 200 301 302 10m;
# fastcgi_cache_use_stale error timeout updating http_500 http_503;
# fastcgi_cache_key "$scheme$request_method$host$request_uri";
# add_header X-Cache $upstream_cache_status;
# 添加无缓存头用于测试
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
2. 临时禁用静态文件缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
# 测试阶段禁用长期缓存
expires -1;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
access_log off;
}
声明:本文为原创文章,版权归旷野小站所有,欢迎分享本文,转载请保留出处!