1) 禁用html文件缓存,即cache control设置为no-cache; 2) 对于js,图片,css,字体等,设置max-age=2592000. 也就是30天; 注意点: - 缓存控制字段cache-control的配置(add_header)要放在http, server, location区域, 或是放在location的if判断里, 例如"add_header Cache-Control no-cache;". - 如果前面有LB负...
要配置nginx以禁用HTML文件的缓存,你可以按照以下步骤操作: 打开nginx配置文件: 通常,nginx的配置文件位于/etc/nginx/nginx.conf,但也可能存在于其他位置,具体取决于你的nginx安装和配置。 找到需要配置不缓存的HTML相关内容的位置: 你需要定位到处理HTML文件的服务器块(server block)或位置块(location block)。例如:...
Cache-Control:no-store 三、nginx配置 location / { #禁止浏览器缓存 index.html 和 version.json if ($request_filename ~* .*\.(htm|html|json)$) { expires -1; #add_header Cache-Control "no-store"; add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate...
html文件设置请求no-cache ,静态资源文件设置缓存时间30天,js/css文件设置缓存12小时
html默认缓存时间配置nginx 前端设置http缓存 缓存的目的 主要作用是可以加快资源获取速度,提升用户体验,减少网络传输,缓解服务端的压力。 强缓存 不需要发送请求到服务端,直接读取浏览器本地缓存,显示的 HTTP 状态码是 200 ,强缓存又分为 Disk Cache (存放在硬盘中)和 Memory Cache (存放在内存中),存放的位置是...
1、直接location匹配 location ~ .*.(htm|html)?$ { add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; } 2、直接在loaction中添加 if 语句 location / { if ($request_filename ~ .*.(htm|html)?$){ ...
location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){ # 最后面的值在上线前可配置为允许的域名地址 valid_referers blocked 192.168.12.129; if ($invalid_referer) { # 可以配置成返回一张禁止盗取的图片 # rewrite ^/ http://xx.xx.com/NO.jpg; ...
<meta http-equiv="pragma" content="no-cache"> nginx配置 由于现在大多都采用了前端框架完成开发,因此部署时大多都是SPA的应用,当然MPA也有很多,那么我们只要让nginx告诉浏览器:我们不需要对html文件使用缓存。 具体的配置如下: server { listen 80; server_name test.exmaple.cn; location / { if ($request...
location/{access_log/data/nginx/log/xxx.log api;root/home/www/html;if($request_filename~.*\.(htm|html)$){add_header Cache-Control no-cache;}} 二. http Headers模块 (设置HTTP报文的头标)Nginx的ngx_http_headers_module模块可以对Cache-Control头相关的东西进行配置, 比如: ...
add_header Cache-Control no-store; } 例三: 1 2 3 location ~ .*\.(js|css)$ { expires 10d; } 例四: 将html结尾的请求加上no-cache 1 2 3 4 5 6 7 8 location / { access_log/data/nginx/log/xxx.log api; root/home/www/html; ...