禁止浏览器缓存- make sure web page is not cached
如何禁止浏览器缓存,网上搜到的解决方法都测试无效。
基本上全都是
Cache-Control: no-cache
Pragma: no-cache
Expires: 0
Google了一下,找到了解决方法。
设置response header 的效果就是 返回的时候一定是重新请求页面的。
Using PHP:
header("Cache-Control: no-cache, no-store, must-revalidate");// HTTP 1.1.
header("Pragma: no-cache");// HTTP 1.0.
header("Expires: 0");// Proxies.
Using Java Servlet, or Node.js:
response.setHeader("Cache-Control","no-cache, no-store, must-revalidate");// HTTP 1.1.
response.setHeader("Pragma","no-cache");// HTTP 1.0.
response.setHeader("Expires","0");// Proxies.
Using ASP.NET:
Response.AppendHeader("Cache-Control","no-cache, no-store, must-revalidate");// HTTP 1.1.Response.AppendHeader("Pragma","no-cache");// HTTP 1.0.Response.AppendHeader("Expires","0");// Proxies.
Using ASP:
Response.addHeader "Cache-Control","no-cache, no-store, must-revalidate"' HTTP 1.1.
Response.addHeader "Pragma","no-cache"' HTTP 1.0.
Response.addHeader "Expires","0"' Proxies.
Using Ruby on Rails, or Python on Flask:
response.headers["Cache-Control"]="no-cache, no-store, must-revalidate"# HTTP 1.1.
response.headers["Pragma"]="no-cache"# HTTP 1.0.
response.headers["Expires"]="0"# Proxies.
Using Google Go:
responseWriter.Header().Set("Cache-Control","no-cache, no-store, must-revalidate")// HTTP 1.1.
responseWriter.Header().Set("Pragma","no-cache")// HTTP 1.0.
responseWriter.Header().Set("Expires","0")// Proxies.
Using Apache .htaccess file:
<IfModulemod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
Using HTML4:
<metahttp-equiv="Cache-Control"content="no-cache, no-store, must-revalidate"/><metahttp-equiv="Pragma"content="no-cache"/><metahttp-equiv="Expires"content="0"/>
HTML meta tags vs HTTP response headers
根据SO上面的说法,
如果通过HTTP访问,HTTP response headers 是优先于 meta tags 的。但
是,第一次打开是通过HTTP访问的,而返回的时候是从本地读取的。
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>index.jsp</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" >
<meta http-equiv="expires" content="0" >
传送门:StackOverFlow
应用
禁止浏览器缓存- make sure web page is not cached的更多相关文章
- Servlet过滤器——使用过滤器禁止浏览器缓存页面
1.概述 IE缓存虽然能提高已储存网站的访问速度,但是过度的IE缓存会影响浏览器的响应速度.同时还可能为网站的运行带来一些不必要的麻烦.例如:可能会因为浏览器缓存的应用,而导致Web服务器不能准确的计 ...
- filter 过滤器 禁止浏览器缓存
public class BrowserNoCacheFilter implements Filter { public void init(FilterConfig filterconfig) th ...
- 禁止浏览器缓存input值
如果不想让浏览器缓存input的值,有2种方法: 方法一: 在不想使用缓存的input中添加 autocomplete="off"; <input type="te ...
- 谷歌浏览器(Chrome)禁止浏览器缓存 设置
在开发项目期间用谷歌浏览器调试,他总是缓存我的css样式这个很气人啊,后经过摸索找到了方法,如下 先F12或者shift+ctrl+j 打开调试者工具,在找Network这个tab按钮,点击进入,勾选 ...
- nginx 禁止浏览器缓存
如果我们使用Nginx作为静态资源服务器,那么可以使用expires进行缓存控制. location /{ expires 1s; } 如果Get页面未做任何修改,服务器就是对客户端返回304 Not ...
- 禁止浏览器缓存js
方法:在js文件后加上数学随机数; Math.random() 比如:源代码为 <script src="./js/lib/require/require.js" data- ...
- ajax禁止浏览器缓存
把cache 设置为false ,把 ifModified 设置为true //工作计划function workprogram(date_time){ $.ajax({ asyn ...
- [原创]java WEB学习笔记45:自定义HttpFilter类,理解多个Filter 代码的执行顺序,Filterdemo:禁用浏览器缓存的Filter,字符编码的Filter,检查用户是否登陆过的Filter
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- 禁止火狐浏览器缓存input标签方法
禁止火狐浏览器缓存input标签方法 问题1:在火狐浏览器里,云平台的输入框.选项框.勾选框…填写之后按F5刷新页面,之前填的东西会保留着,其它浏览器不会火狐强制刷新用Ctrl + F5 浏览器自动保 ...
随机推荐
- 7.Sentinel源码分析—Sentinel是怎么和控制台通信的?
这里会介绍: Sentinel会使用多线程的方式实现一个类Reactor的IO模型 Sentinel会使用心跳检测来观察控制台是否正常 Sentinel源码解析系列: 1.Sentinel源码分析-F ...
- Java查询判断素数实验报告
实验源代码: package sushu; import java.util.Scanner; public class First { int size=2; int data[]=new int[ ...
- 在Docker中启动Cloudera
写在前面 记录一下,一个简单的cloudera处理平台的构建过程和一些基本组件的使用 前置说明 需要一台安装有Docker的机器 docker常用命令: docker ps docker ps -a ...
- 【Dgango】模版
继承 ① extends用法:只继承一个模版 <!DOCTYPE html> <html lang="en"> <head> <meta ...
- java8泛型
目录 1,泛型中的相关操作符 2,泛型基本使用示例 3,通配符 3.1, T和?的区别 3.2,上下界通配符 4, 附加约束(&) 泛型,也就是将类型参数化,然后在使用类或者方法的时候可以 ...
- Django之使用haystack+whoosh实现搜索功能
为了实现项目中的搜索功能,我们使用的是全文检索框架haystack+搜索引擎whoosh+中文分词包jieba 安装和配置 安装所需包 pip install django-haystack pip ...
- python beautiful soup
官方文档:https://www.crummy.com/software/BeautifulSoup/bs4/doc.zh/ 使用前需要先安装模块,并安装解析器 pip install beautif ...
- windows下python和pycharm安装及其使用
1.python安装及环境变量配置 1.1 python安装 1.1.1 python下载 官网下载:https://www.python.org/ Downloads-Windows(Mac os ...
- 集合线性表--List之ArrayList
集合操作——线性表 List: add().remove().subList().list.toArray().array.asList(). List排序: Collections.sort(li ...
- Scala 学习笔记之函数(2)
class OldStudent extends Student { def filterName(s: String, f: String => String) = { if (s != nu ...