定位 发表于 4 天前

discuz配置游客默认缓存(针对固定页面)

nginx.conf里面配置:
fastcgi_cache_path /usr/local/nginx/data/cache levels=1:2 keys_zone=discuz:100m max_size=2g inactive=7d use_temp_path=off;

enable-php.conf内配置:
        location ~ [^/]\.php(/|$)
        {
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;

            set $skip_cache 1;

              if ($request_uri ~* "^/(thread-\d+-\d+-\d+\.html|forum-\d+-\d+\.html)$"){
                        set $skip_cache 0;
              }

                  if ($cookie_8skG_2132_auth){
                  set $skip_cache 1;
              }

              if ($request_method = POST){
                  set $skip_cache 1;
              }

                fastcgi_cache discuz;
                fastcgi_cache_key "$request_method$host$request_uri";
                fastcgi_cache_valid 200 3m;
                fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;
                fastcgi_cache_use_stale error timeout updating http_500 http_503;
                fastcgi_cache_lock on;
                add_header X-Cache-Status $upstream_cache_status;
        }


观察浏览器响应头内是否有X--Cache-Status,且值为HIT

页: [1]
查看完整版本: discuz配置游客默认缓存(针对固定页面)