ASP技巧:禁用清除页面缓存的五种方法
发布时间:2009-07-21 12:33:00
1、在Asp页面首部加入
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache"
2、在HtML代码中加入
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>
3、在重新调用原页面的时候在给页面传一个参数 Href="****.asp?random()"
前两个方法据说有时会失效,而第三种则是在跳转时传一个随机的参数! 因为aspx的缓存是与参数相关的,假如参数不同就不会使用缓存,而会重新生成页面,每次都传一个随机的参数就可以避免使用缓存。这个仅适用于asp&asp.net
4、在jsp页面中可使用如下代码实现无缓存:
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server 这些代码加在<head> </head>中间具体如下
<head>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
</head>
5、window.location.replace("WebForm1.aspx");
参数就是你要覆盖的页面,replace的原理就是用当前页面替换掉replace参数指定的页面。
这样可以防止用户点击back键。使用的是javascript脚本,举例如下:
a.html
<html>
<head>
<title>a</title>
<script language="javascript">
function jump(){
window.location.replace("b.html");
}
</script>
</head>
<body>
<a href="javascript:jump()">b</a>
</body>
</html>
b.html
<html>
<head>
<title>b</title>
<script language="javascript">
function jump(){
window.location.replace("a.html");
}
</script>
</head>
<body>
<a href="javascript:jump()">a</a>
</body>
</html>
前4种只是清空了cache,即存储在Temporary Internet Files文件夹中的临时文件,而第五种则是使用跳转页面文件替换当前页面文件,并没有清空cache,也就是说Temporary Internet Files产生了相关的临时文件,两者搭配使用真是清空缓存,必备良药。正好我这里有了记录,所以常来看看哦。
猜你喜欢
- '-----------------------------------------------------------
- 今天用vue来实现一个分页组件,总体来说,vue实现比较简单,样式部分模仿了elementUI。所有代码的源码可以再github上下载的到:
- 1.字符串处理将字符串中的数字替换成其两倍的值,例如:修改前:"AS7G123m (d)F77k"修改后:"A
- 1. 准备工作首先编写getHtml函数,传入markdown文本字符串,这里使用fs读取markdown文件内容,返回值是转换过后的字符串
- python中列表的常见操作列表元组的简单操作前面我们已经学过了关于len()函数、赋值运算符及身份运算符的使用,下面简单回顾一下这些在列表
- 1.v-for直接上代码。示例一:<!DOCTYPE html><html><head> <met
- 目录查找算法 -- 简介顺序查找二分查找插值查找斐波那契查找树表查找1、二叉树查找算法。2、平衡查找树之2-3查找树(2-3 Tree)3、
- PPT链接说实话,看到这个题目时我觉得这有什么好讨论的,肯定会是场一边倒的讨论。因为个人比较倾向于短命名,简单优雅,可能是出于程序员的洁癖,
- 想用go做一个统计svn代码提交的工具,类似statsvn。今天进展到了用go解析svn log生成的xml格式的文件,在go doc上找了
- 代码很简单,会继续完善。。。 按住鼠标键不动,拖动鼠标,会看到效果 <html> <head&
- 本文重点系统分析网页性质结构化的数据解析csv数据保存环境介绍python 3.8pycharm 专业版 >>> 激活码#
- mysql中using的用法为:using()用于两张表的join查询,要求using()指定的列在两个表中均存在,并使用之用于join的条
- 定义:Dim MyArray() Redim MyArray(5)Session("StoredAr
- 本文实例讲述了Laravel框架路由管理。分享给大家供大家参考,具体如下:路由中输出视图Route::get('/', fu
- Python的可视化工具有很多,数不胜数,各有优劣。本文就对其中的pylab进行介绍。之所以介绍这一款,是因为它和Matlab的强烈相似度,
- 外联接。外联接可以是左向外联接、右向外联接或完整外部联接。 在 FROM 子句中指定外联接时,可以由下列几组关键字中的一组指定:LEFT J
- 对于一个多维数组(以二维数组为例),经常需要获取到其中的一列,比如有几条用户数据,是一个二维数组,现在需要获取到这几个用户的名字,可以有多种
- 什么是随机数随机数并不意味着每次都有不同的数字。随机意味着无法在逻辑上预测的事物。伪随机和真随机计算机在程序上工作,程序是权威的指令集。因此
- 前言优化随机森林算法,正确率提高1%~5%(已经有90%+的正确率,再调高会导致过拟合)论文当然是参考的,毕竟出现早的算法都被人研究烂了,什
- 用下面方法解决(管理mysql用的是navicat).,设置以下几个参数的值后就正常了,以下语句也可以在mysql的控制台上执行 . sho