表单重复提交2_禁止浏览器缓存
来源:互联网 发布:好看的搞笑网络短剧 编辑:程序博客网 时间:2024/05/21 12:35
禁止浏览器缓存-
基本上全都是
Cache-Control: no-cachePragma: no-cacheExpires: 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:
<IfModule mod_headers.c> Header set Cache-Control "no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires 0</IfModule>
Using HTML4:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /><meta http-equiv="Pragma" content="no-cache" /><meta http-equiv="Expires" content="0" />
HTML meta tags vs HTTP response headers
根据SO上面的说法,如果通过HTTP访问,HTTP response headers 是优先于 meta tags 的。但
是,第一次打开是通过HTTP访问的,而返回的时候是从本地读取的。
我在自己尝试的时候,发现这两个都需要设置 才能清除页面表单记录。Google浏览器 和 IE11测试通过,页面的记录消除。其他的浏览器未测试。(推测是因为上面的原因)
如果多次测试发现 页面表单的记录还在。
但是可以保证,只要写了HTTP response headers 返回的时候一定会重新请求。
部分代码如下
0 0
- 表单重复提交2_禁止浏览器缓存
- 禁止表单重复提交
- 禁止表单里重复提交
- struts2禁止表单重复提交
- 小TIPS:禁止表单里重复提交
- 前端禁止多次重复提交表单
- 小TIPS:禁止表单里重复提交
- struts2禁止表单重复提交 demo
- 禁止重复提交(JavaScript控制表单…
- JS控制form表单提交时增加随机数参数,防止浏览器缓存,重复提交
- jquery提交form表单时禁止重复提交的方法
- 如何禁止重复提交
- 如何禁止重复提交
- 如何禁止重复提交
- C#禁止重复提交
- C#禁止重复提交
- from表单禁止提交
- 禁止回车提交表单
- java常用的几种线程池比较
- ECharts 3.0源码简要分析1-总体架构
- MapReduce简介
- NetworkError: 500 Internal Server Error
- Greenplum数据库开发
- 表单重复提交2_禁止浏览器缓存
- MSSQL编程笔记四 解决count distinct多个字段的方法
- 用于字节对齐的宏
- 【Android】非 recreate() 形式的夜间模式实现(自由切换,不改变任何状态,不重新初始化整个activity)
- 【总结】Hadoop-2.X HA模式下的FSImage和EditsLog合并过程
- React-scripts 如何快速创建调试一个Demo程序
- 面向对象--第一篇
- myEclipse如何查看部署的项目名称
- 数据双向绑定练习demo