Prevent caching of a JSP outputFrom WikiJava
This example shows how to prevent the browser to cache the content of a JSP.
the articleYou will need to set the appropriate HTTP header attributes. see #for all the browsers However, cache handling is tricky with IE brower. See http://support.microsoft.com/kb/q222064/. By adding a second HEAD is supposed to solve the problem! see #specifically for Internet explorer. NOTE: Pragma: no-cache prevents caching only when used over a secure connection, Expires: -1 should do the job over unsecure connection. for all the browsers<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>specifically for Internet explorer<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
my page body
</BODY>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
</HTML>See Alsohttp://www.rgagnon.com/jsdetails/js-0014.html, http://www.rgagnon.com/jsdetails/js-0031.html, Real's Java How To |

Caching of JSP output? ... as far as I know, JSP pages are compiled to servlets at the end of story... and saying JSP output caching would have to be related then to output stream caching (and we very want to have it here), anyway everyone know that it's about information transported within HTTP protocol that can be used by applications handling data exchange via mentioned protocol. Thing about JSPs and actually web page content (not only HTML, it can be image , text or anything else) caching is not that straight for real, caching can be done in many layers of transport model, lets imagine that we have: - server - proxy - client browser ( here it is also important what is the type of browser (IE,Gecko,WebKit etc. , they all try to apply standards, but if you start creating complicated software - difference will come out.) The most annoying caching is done via proxy servers (to decrease data transfers - typically in modem connection providers), in proxy "they" try generally to review HTTP headers and also data content (that last one isn't even legal in some countries). Browsers react with HTTP headers and content, but generally there is an order: HTML headers have higher priority than HTTP.
This article should rather be about "How to omit caching." - which is for real much more difficult task.
--86.163.174.232 17:41, 27 November 2008 (UTC)