浏 览器为了加速使用者的浏览速度,常会将浏览过的网页快取到硬盘,下次浏览同一页时,便去硬盘里面去找,但现在的网页常是动态的,为了避免使用者抓到硬盘内 过期的数据,JSP可用下面的方式来防止浏览器快取住网页,此方法便可保证使用者到这个网页时始终都可看到最新的资料。<o:p></o:p>
<o:p> </o:p>
1.JSP语法 <o:p> </o:p>
<%
response.setHeader( " Pragma " , " no-cache " );
response.setHeader( " Cache-Control " , " no-cache " );
response.setDateHeader( " Expires " , 0 );
%>
response.setHeader( " Pragma " , " no-cache " );
response.setHeader( " Cache-Control " , " no-cache " );
response.setDateHeader( " Expires " , 0 );
%>
<o:p> </o:p>
<o:p> </o:p>
2.也可以用以下的HTML语法,可用在静态网页上 <o:p> </o:p>
<
meta http
-
equiv
=
"
Pragma
"
content
=
"
no-cache
"
>
< meta http - equiv = " Cache-Control " content = " no-cache " >
< meta http - equiv = " Expires " content = " 0 " >
< meta http - equiv = " Cache-Control " content = " no-cache " >
< meta http - equiv = " Expires " content = " 0 " >
<o:p> </o:p>
注意,这些HTML语法要下在<head></head>的标签内。