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-ControlandPragmaheaders. Swap them. Firefox namely also requiresno-storeandmust-revalidatealong theno-cache.Even more, only the
no-cache,no-store,must-revalidatehas been enough forCache-Controlto get it to work across browsers.See also:
Unrelated to the concrete problem, I’d recommend to put this piece of code in a
Filterclass which you map on*.jspinstead of copypasting the same code over all JSP files for which you’d like to disable the browser cache.