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";
    }
相关推荐
Csvn2 小时前
Nginx 静态站点与 location 匹配:优先级、alias、缓存头与 gzip
后端·nginx
考虑考虑4 小时前
nginx拦截url
运维·后端·nginx
李纲明15 小时前
WordPress 打开站点却直接下载文件或源码而不显示页面:先核 PHP 处理规则,再查 443 是否被其他站接管
nginx·wordpress·443·php解析·站点配置·devdiy·直接下载
Java码农也是农1 天前
一篇文章讲清 NGINX 反向代理:location、proxy_pass、负载均衡与排错
nginx·负载均衡·后端开发·反向代理·proxy_pass
2501_933923251 天前
redis:string类型常见命令
数据库·redis·缓存
黄连木笛2 天前
Redis Insight 汉化教程:Windows / macOS / Linux 设置中文界面(附繁體、教程汉化、关闭自动更新)
数据库·redis·缓存
李纲明2 天前
WordPress 打开页面直接报 500 而不是白屏:先核伪静态与文件权限,再查服务器错误日志
nginx·wordpress·文件权限·伪静态·错误日志·devdiy·500错误
威嵌神州2 天前
嵌入式排故实录:高并发下串口数据“超时丢包”的根因剖析与架构优化
运维·服务器·嵌入式硬件·缓存
nice_lcj5203 天前
LRU 缓存入门:它是什么、怎么用、面试怎么手写
java·数据结构·缓存·面试·lru
Csvn3 天前
Nginx 配置语法与上下文:一次搞懂继承、变量与用 map 替掉 if
后端·nginx