nging Fastcgi_cache缓存问题

查看 29|回复 0
作者:llcn168   
   
看了下张戈的这篇文章https://zhangge.net/5042.html关于nging Fastcgi_cache缓存的配置
请问各位大佬nging Fastcgi_cache的缓存插件怎么缓存不同页面的缓存时间设置不一样?
我自己location ~ /info/([0-9]+)/$缓存这个伪静态的规则,好像缓存不起作用,还是只匹配缓存下面的location ~ [^/]\.php(/|$)的缓存时间
[ol]
#Fastcgi_cache缓存开始        
# 跳过缓存开关,1为跳过缓存,0为不跳过缓存
set $skip_cache 0;
#post访问不缓存,
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;
}
#缓存伪静态book开头的所有页面/好像没用
location ~ /info/([0-9]+)/$
{
        try_files $uri =404;
        fastcgi_pass unix:/tmp/php-cgi-73.sock;
        fastcgi_index index.php;
        include enable-php-73.conf;
        #缓存规则
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        add_header X-Cache "$upstream_cache_status From $host";
        #注意!cgi_one的缓存名,keys_zone=cgi_one叫什么,这里就填什么名。
        fastcgi_cache cgi_one;
        fastcgi_cache_valid 200 301 302 60s;
        fastcgi_cache_valid 404 500 502 503 504 0s;
        fastcgi_cache_valid any 0s;
}
location ~ [^/]\.php(/|$)
{
        try_files $uri =404;
        fastcgi_pass unix:/tmp/php-cgi-73.sock;
        fastcgi_index index.php;
        include enable-php-73.conf;
        #缓存规则
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        add_header X-Cache "$upstream_cache_status From $host";
        #注意!cgi_one的缓存名,keys_zone=cgi_one叫什么,这里就填什么名。
        fastcgi_cache cgi_one;
        fastcgi_cache_valid 200 301 302 1d;
        fastcgi_cache_valid 404 500 502 503 504 0s;
        fastcgi_cache_valid any 0s;
}[/ol]复制代码

缓存, 跳过, 规则

您需要登录后才可以回帖 登录 | 立即注册

返回顶部