Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It might at that point be <em>too late</em> to change the response headers. They will simply be ignored. You can verify the presence of response headers in a HTTP debugger tool like <a href="http://getfirebug.com" rel="nofollow noreferrer">Firebug</a>.</p> <hr> <p><img src="https://i.stack.imgur.com/NVqah.png" alt="alt text"></p> <hr> <p>In the JSP, you need to ensure that they are set <em>before</em> the response is committed (i.e. all headers are already sent; you cannot send another headers afterwards). I.e. ensure that they are in the very top of the JSP file and that no template text is before that piece of <em>scriptlet</em>. Template text may cause a commit of the response. The normal practice, however, is to use a <code>Filter</code> for this. </p> <p>Implement <a href="http://download.oracle.com/javaee/6/api/javax/servlet/Filter.html" rel="nofollow noreferrer"><code>javax.servlet.Filter</code></a> wherein <code>doFilter()</code> method look like follows:</p> <pre><code>HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.setHeader("Cache-Control", "no-cache", "no-store", "must-revalidate"); // HTTP 1.1 httpResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0 httpResponse.setDateHeader("Expires", 0); // Proxies. chain.doFilter(request, response); </code></pre> <p>Map this in <code>web.xml</code> on an <code>url-pattern</code> of <code>*.jsp</code> and it ought to work.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers">Making sure a webpage is not cached, across all browsers</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload