[nginx] fastcgi_cache 完整示例


    # 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;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值