在Firefox中停止缓存

sha*_*han 5 java jsp caching meta-tags

我正在使用以下代码.

<%
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);
%>
Run Code Online (Sandbox Code Playgroud)

它在IE中完美运行,但页面仍然在Firefox中缓存.我想在Firefox中停止缓存.有什么建议?

Bal*_*usC 10

你很困惑Cache-ControlPragma标题.交换它们.Firefox也需要no-storemust-revalidate沿着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);
Run Code Online (Sandbox Code Playgroud)

更重要的是,只有它no-cache,no-store,must-revalidate足以Cache-Control让它跨浏览器工作.

也可以看看:


与具体问题无关,我建议将这段代码放在Filter您映射的类中,*.jsp而不是在您要禁用浏览器缓存的所有JSP文件上复制相同的代码.