Header Ads

  • Breaking Now

    How can you prevent caching in JSP?

    Execute the following scriptlet at the beginning of your JSP pages  to prevent JSPs from being cached by browsers.You need both the statements to  take care of some of the older browser versions.

    <%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
    %>

     If the above fails, try changing the first line to

    response.setHeader("Cache-Control","no-store"); //HTTP 1.1

    Post Top Ad

    Post Bottom Ad