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">
相关推荐
白鸽(二般)2 小时前
MinIO Java Client API
java·开发语言
敲个大西瓜2 小时前
Redis一百道核心面试题
数据库·redis·缓存
软萌萌的12 小时前
Java Spring Boot 修改yml配置&加载顺序规则
java·spring boot·python
IT小盘3 小时前
13-企业Prompt模板-角色任务约束与输出格式
java·前端·prompt
爱敲键盘的猴子3 小时前
Java并发编程 -- volatile
java·java并发
plainGeekDev5 小时前
工厂模式 → Hilt
android·java·kotlin
plainGeekDev5 小时前
Application 单例 → Hilt Singleton
android·java·kotlin
888CC++5 小时前
C语言与C++的区别:从面向过程到面向对象
java·c语言·c++
学者猫头鹰6 小时前
分布式事务实战教程
java·分布式
heimeiyingwang7 小时前
【架构实战】Kubernetes调度器深度剖析:从Pod调度到自定义调度器
java·架构·kubernetes