缓存-为什么Nginx不缓存我的内容?
作者:互联网
我检查了缓存路径/usr/local/nginx / proxy_cache.我多次访问某些网址后未找到缓存文件.
我的配置:
ngnix.conf
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_temp_file_write_size 128k;
proxy_temp_path /usr/local/nginx/proxy_temp;
proxy_cache_path /usr/local/nginx/proxy_cache levels=1:2 keys_zone=content:20m inactive=1d max_size=100m;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
默认
server {
listen 80;
server_name 208.115.202.87;
location /test {
proxy_cache content;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 15m;
proxy_pass http://aaa.com/;
}
解决方法:
nginx不缓存设置cookie的页面,
检查您的页面是否具有Set-Cookie标头.
如有必要,可以使用proxy_ignore_headers忽略cookie,并使用proxy_hide_header禁止显示cookie.例如:
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;
标签:caching,nginx,proxy,reverse-proxy 来源: https://codeday.me/bug/20191010/1888595.html