全球主机交流论坛
标题:
nging Fastcgi_cache缓存问题
[打印本页]
作者:
llcn168
时间:
2023-9-16 17:55
标题:
nging Fastcgi_cache缓存问题
本帖最后由 llcn168 于 2023-9-16 17:59 编辑
看了下张戈的这篇文章
https://zhangge.net/5042.html
关于nging Fastcgi_cache缓存的配置
请问各位大佬nging Fastcgi_cache的缓存插件怎么缓存不同页面的缓存时间设置不一样?
我自己location ~ /info/([0-9]+)/$缓存这个伪静态的规则,好像缓存不起作用,还是只匹配缓存下面的location ~ [^/]\.php(/|$)的缓存时间
#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;
}
复制代码
作者:
tiga
时间:
2023-9-16 18:27
同样 location ~,当然后面的生效
location ~ /info/([0-9]+)/$
复制代码
改为
location ^~ /info/([0-9]+)/$
复制代码
不让它往后匹配就行了
作者:
llcn168
时间:
2023-9-16 18:42
tiga 发表于 2023-9-16 18:27
同样 location ~,当然后面的生效
这个也试过 ,还是匹配下面的PHP缓存时间,我不知道这个Fastcgi_cache缓存插件是不是不缓存伪静态地址
欢迎光临 全球主机交流论坛 (https://fd.vvwvv.eu.org/)
Powered by Discuz! X3.4