
标题: 请教下,如何反代缓存全部文件? [打印本页]
作者: a7898585 时间: 2017-11-20 15:15 标题: 请教下,如何反代缓存全部文件?
因为伪静态导致CPU 一直100%现在想用反代,把全部页面都缓存成静态的
请教下该怎么修改conf才能把html,js和图片都缓存下来呢
作者: licess 时间: 2017-11-20 18:36
https://www.vpser.net/manage/linux-vps-nginx-reverse-proxy.html
再加上
proxy_cache fandai_cache;
proxy_cache_key %s$request_uri$is_args$args;
proxy_cache_valid 200 304 301 302 1h;
上面缓存时间1h可以自己调整一下
nginx.conf 里或者server段前加上
proxy_cache_path /home/fandai_cache levels=1:2 keys_zone=fandai_cache:10m max_size=10g;
proxy_cache_key "$host$request_uri";
目录都提前创建好
作者: a7898585 时间: 2017-12-3 22:50 标题: 回复 2# 的帖子
请教下军哥,是按下面这样吗?html和js如何指定保存?
我在home下新建了fandai_cache文件夹了,然后修改了 /usr/local/nginx/conf/vhost 对应的网站conf文件
proxy_cache_path /home/fandai_cache levels=1:2 keys_zone=fandai_cache:10m max_size=10g;
proxy_cache_key "$host$request_uri";
server
{
listen 80;
server_name www.kwxonline.com;
location / {
proxy_pass http://www.kwx.gd/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache fandai_cache;
proxy_cache_key %s$request_uri$is_args$args;
proxy_cache_valid 200 304 301 302 24h;
}
}
作者: a7898585 时间: 2017-12-3 22:51 标题: 回复 2# 的帖子
请教下军哥,是按下面这样吗?html和js如何指定保存?
我在home下新建了fandai_cache文件夹了,然后修改了 /usr/local/nginx/conf/vhost 对应的网站conf文件
proxy_cache_path /home/fandai_cache levels=1:2 keys_zone=fandai_cache:10m max_size=10g;
proxy_cache_key "$host$request_uri";
server
{
listen 80;
server_name www.kwxonline.com;
location / {
proxy_pass http://www.kwx.gd/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache fandai_cache;
proxy_cache_key %s$request_uri$is_args$args;
proxy_cache_valid 200 304 301 302 24h;
}
}
作者: licess 时间: 2017-12-4 13:05
添加上个location复制内容到剪贴板
代码:
location ~ .*\.(html|js)$
{
proxy_cache fandai_cache;
proxy_cache_key %s$request_uri$is_args$args;
proxy_cache_valid 200 304 301 302 1h;
}
试试
作者: a7898585 时间: 2017-12-4 14:48 标题: 回复 5# 的帖子
额,这代码加哪没看懂了,能完整的写一下吗。。。
欢迎光临 VPS侦探论坛 (http://bbs.vpser.net/) |
Powered by Discuz! 6.0.0 |