缓存远程类型并为新用户显示非法IP。它有助于等待3-10秒或重启nginx。如何完全关闭缓存?
操作系统:Centos 7
nginx版本:nginx / 1.10.2
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name test.mydomain.org;
root /etc/nginx/html;
index index.html;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Cache-Control' 'no-cache';
default_type text/plain;
return 200 "$remote_addr";
}
# Error page
error_page 404 /404;
}
}
答案 0 :(得分:3)
您看到的缓存来自浏览器缓存。 清除浏览器缓存并在重置位置conf后尝试该页面以包括:
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
这使得绝对确保浏览器或任何中间代理不会缓存发送的输出。
答案 1 :(得分:0)
在nginx conf文件中使用此配置
location /path-to-files/ {
directio 0;
}
将绕过操作系统级别的缓存。