为啥我 Nginx 下启用 fastcgi_cache 不生成缓存? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cpublic
V2EX    NGINX

为啥我 Nginx 下启用 fastcgi_cache 不生成缓存?

  •  1
     
  •   cpublic 2017-08-06 14:39:46 +08:00 3178 次点击
    这是一个创建于 3036 天前的主题,其中的信息可能已经有所发展或是发生改变。
    先说说我在 nginx.conf 里 http 里的配置,如下:

    fastcgi_cache_path /var/domain_cache levels=1:2 keys_zOne=domain:100m inactive=1d max_size=5G;
    fastcgi_temp_path /var/cache_temp;
    fastcgi_cache_key "$scheme$request_method$host$request_uri"; #定义哪些情况下用过期缓存
    fastcgi_cache_use_stale error timeout invalid_header http_500 http_503 updating;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie Vary;
    然后是我的域名 myhost.conf 文件内的 Fastcgi_cache 有关配置,如下:

    set $skip_cache 0;

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

    if ($query_string != "") {
    set $skip_cache 1;
    }

    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
    set $skip_cache 1;
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
    set $skip_cache 1;
    }


    location ~ [^/]\.php(/|$)
    {
    try_files $uri =404;
    fastcgi_pass unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    add_header X-Cache-Status $upstream_cache_status;
    add_header X-Cache "$upstream_cache_status From $host";
    fastcgi_cache domain;
    fastcgi_cache_valid 200 301 302 1d;
    }

    location ~ /purge(/.*) {
    allow 127.0.0.1;
    allow "111.112.113.114";
    deny all;
    fastcgi_cache_purge domain "$scheme$request_method$host$1";
    }

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off; log_not_found off; expires max;
    }

    location = /robots.txt { access_log off; log_not_found off; }
    location ~ /\. { deny all; access_log off; log_not_found off; }
    WordPress 里安装了 nginx-helper 插件,通过 tailf 命令查看这个插件生成的.log 文件一直是如下显示:

    https://segmentfault.com/img/bVSke7?w=284&h=231
    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     854 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 20:39 PVG 04:39 LAX 12:39 JFK 15:39
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86