开发者

Stop caching in Firefox

开发者 https://www.devze.com 2023-02-17 19:19 出处:网络
I am开发者_如何转开发 using following code. <% response.addHeader(\"Cache-Control\",\"no-cache\");

I am开发者_如何转开发 using following code.

<%
response.addHeader("Cache-Control","no-cache"); 
response.addHeader("Pragma","no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0 "); 
response.addDateHeader ("Expires", 0);
%>

It works perfectly in IE, but the page is still cached in Firefox. I want to stop caching in Firefox as well. Any suggestions?


You're confusing Cache-Control and Pragma headers. Swap them. Firefox namely also requires no-store and must-revalidate along the no-cache.

response.addHeader("Cache-Control", "no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0"); 
response.addHeader("Pragma", "no-cache"); 
response.addDateHeader ("Expires", 0);

Even more, only the no-cache,no-store,must-revalidate has been enough for Cache-Control to get it to work across browsers.

See also:

  • Caching tutorial for webauthors and webmasters
  • Making sure a webpage is not cached, across all browsers

Unrelated to the concrete problem, I'd recommend to put this piece of code in a Filter class which you map on *.jsp instead of copypasting the same code over all JSP files for which you'd like to disable the browser cache.

0

精彩评论

暂无评论...
验证码 换一张
取 消