Nginx配置不缓存html

Nginx配置不缓存html

    • [1. 配置nginx不缓存html](#1. 配置nginx不缓存html)
      • [1.1 修改配置文件](#1.1 修改配置文件)
      • [1.2 验证](#1.2 验证)
    • [2. Vue项目修改根目录index.html](#2. Vue项目修改根目录index.html)

1. 配置nginx不缓存html

1.1 修改配置文件

bash 复制代码
location / {
 expires 1h;
 root /home/html;
 index index.html index.htm;
 ## html不缓存 
 if ($request_filename ~* .*\.(htm|html)$){
     add_header Cache-Control "no-store";
 }
}

1.2 验证

2. Vue项目修改根目录index.html

html 复制代码
//head中添加以下代码,会使所有打css/js资源重新加载
<meta http-equiv="pragram" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
相关推荐
St_rive4 小时前
Page Object设计模式
java·开发语言·设计模式
风流 少年5 小时前
Spring AI 2.0:SSE
java·人工智能·spring
凤山老林5 小时前
精细化流量治理:Spring Boot 动态特性开关与灰度发布体系
java·spring boot·后端
何以解忧,唯有..6 小时前
深入理解与应对:Redis 缓存雪崩、击穿、穿透三大经典问题
redis·缓存·mybatis
Aphelios3807 小时前
一次锁内网络IO引发的Tomcat线程池“饿死”事故
java·开发语言·spring boot·elasticsearch·tomcat·网络io阻塞·线程池耗尽
不可求~8 小时前
C++ std::string_view 不是字符串:从悬空引用到安全用法
java·开发语言·c++
Lam Tang8 小时前
APS 系列文章10
java·代理模式
考虑考虑8 小时前
Excel导入时产生特殊字符处理
java·后端·java ee
Scabbards_9 小时前
面试Leetcode - Heap 堆
java·leetcode·面试
用户938515635079 小时前
Docker + Nginx + Node.js:从“我的电脑能跑,你的电脑跑不了”到一键部署
后端·nginx·docker