# http 区域设置的缓存参数
# fastcgi_temp_path 和 fastcgi_cache_path 指定的路径必须在同一分区
fastcgi_temp_path xxxxx;
#设置 web 缓存区名称为 cache_one,内存缓存空间大小为 500MB,自动清楚超过 1 天没有被访问的缓存数据,硬盘缓存空间大小为 30GB.
fastcgi_cache_path xxxxx levels=1:2 keys_zone=cache_one:500m inactive-1d max_size=30g;
server
{
listen 80;
server_name my.domain.com;
root xxxx;
location ~ .*\.(php|php5)$
{
#使用 web 缓存区 cache_one
fastcgi_cache cache_one;
#对不同 HTTP 状态码缓存设置不同的缓存时间
fastcgi_cache_vaild 200 10m;
fastcgi_cache_vaild 301 302 1h;
fastcgi_cache_vaild any 1m;
#设置 web 缓存的 key 值,nginx 根据 key 值 MD5 哈希存储缓存,这里根据 “FastCGI 服务器的 IP、端口、请求的 URI” 组合成 key
fastcgi_cache_key 127.0.0.1:9000$request_uri;
#FastCGI 服务器
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
access_log off;
}
[nginx] fastcgi_cache 完整示例
最新推荐文章于 2024-06-25 07:00:00 发布