网页端如何禁止缓存?

文章类型:行业资讯    发表2010-11-13   文章编辑:怒熊网络 · 一站式互联网+技术服务商!   阅读:321

有时在网页制作时并不太希望网页保存缓存,比如在填写表单返回时,又或者在登陆退出后直接输入地址还能回到缓存页面,这时后你不用想破脑袋来解决如果返回刷新数据的问题,网页端禁止缓存就行了。

HTML禁止网页缓存方法:
<META HTTP-EQUIV='pragma' CONTENT='no-cache'>
<META HTTP-EQUIV='Cache-Control' CONTENT='no-store, must-revalidate'>
<META HTTP-EQUIV='expires' CONTENT='Wed, 26 Feb 1997 08:21:57 GMT'>
<META HTTP-EQUIV='expires' CONTENT='0'>

ASP禁止网页缓存方法:
response.expires=0
response.addHeader('pragma','no-cache')
response.addHeader('Cache-Control','no-store, must-revalidate')

PHP网页禁止缓存方法:
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, must-revalidate');
header('Pragma: no-cache');

JSP网页禁止缓存方法:
response.addHeader('Cache-Control', 'no-store, must-revalidate');
response.addHeader('Expires', 'Thu, 01 Jan 1970 00:00:01 GMT');