nginx配置不缓存资源

方法1

conf 复制代码
        location / {
            index  index.html index.htm;
            add_header Cache-Control no-cache,no-store;
            try_files $uri $uri/ /index.html;
            #include mime.types;
            if ($request_filename ~* .*\.(htm|html)$) 
            {
              add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
            }
        }

方法2

conf 复制代码
        location / {
            index  index.html index.htm;
            add_header Cache-Control no-cache,no-store;
            try_files $uri $uri/ /index.html;
            #include mime.types;
            #if ($request_filename ~* .*\.(htm|html)$) 
            #{
            #  add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
           # }
        }
       location = /index.html {
            #add_header Cache-Control "no-cache, no-store, must-revalidate";
            add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
            add_header Pragma "no-cache";
            add_header Expires "0";
    }
相关推荐
斌味代码1 天前
Nginx 配置实战(2026最新版):反向代理+负载均衡+HTTPS+性能优化一网打尽
nginx·https·负载均衡
皙然1 天前
深入拆解缓存一致性:从原理到实战,彻底解决数据不一致难题
缓存
皙然1 天前
深入拆解MESI协议:从原理到实战,搞懂CPU缓存一致性的核心机制
java·缓存
qzhqbb1 天前
Web 服务器(Nginx、Apache)
服务器·前端·nginx
深蓝轨迹1 天前
Redis 消息队列
java·数据库·redis·缓存·面试·秒杀
于樱花森上飞舞1 天前
【Redis】初识Redis
数据库·redis·缓存
山楂树の1 天前
【计算机系统原理】Intel 与 AT&T 汇编指令格式转换
汇编·学习·缓存
山楂树の1 天前
【计算机系统原理】 直接映射(模映射) Cache 地址划分与访问过程
学习·缓存
cyforkk1 天前
缓存穿透难题:当 Value 为空字符串时,该如何优雅处理?
缓存
呆子也有梦1 天前
redis 的延时双删、双重检查锁定在游戏服务端的使用(伪代码为C#)
redis·后端·游戏·缓存·c#