网站制作学习网经验与学习→正文:nginx cache缓存php 伪静态
字体:

nginx cache缓存php 伪静态

经验与学习 2023/6/29 15:18:03  点击:不统计

原载于:文章来源:www.forasp.cn网站制作学习

 
nginx proxy_cache缓存伪静态 php html文件,配置如下
 
location / {
proxy_cache cache_one; # 缓存区
proxy_cache_key $ismobile$host$server_port$request_uri; # 用什么作为缓存的key ,一般是url/uri 有的用 $scheme ,这里用端口$server_port代替了
proxy_cache_valid  200 304 20m;# 缓存条件 upstream 是200 或者304 缓存时间20分钟。 也可以设置为 1d 1天
proxy_cache_methods GET; # 缓存的方法,如果要有其他方法不缓存
add_header X-Cache $upstream_cache_status; #将缓存是否命中的结果返回
proxy_ignore_headers Set-Cookie; # 这里是定义忽略cookie header到后端。如果是动态网页,或者php 没有这个配置,就会一直miss
proxy_pass https://forasp_ssl;
}
 
 如果没有 proxy_ignore_headers Set-Cookie;就会一直miss,它是将本地cookie 一直传递个upstream,所以一直不缓存。
设置了之后,就会缓存

·上一篇:Iphone刷机 >>    ·下一篇:nginx 配置cache 做CDN >>
推荐文章
最新文章