pankaj369
pankaj369

Reputation: 119

How to Remove cache in spring mvc 3 (Back Button and refresh should not work)

My code is this :

<%
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Cache-Control", "no-store");
            response.setDateHeader("Expires", 0);
            response.setHeader("Pragma", "no-cache");
%>

    ${Sess_Var}
     <c:if test="${empty Sess_Var}" >
<%
response.sendRedirect("doLogin.obj");
%>       

It is Not working because on clicking on back button it show the previous page.. What should i do?

Upvotes: 3

Views: 3316

Answers (1)

D&#233;j&#224; vu
D&#233;j&#224; vu

Reputation: 28830

You have to provide the browser (client) with the correct headers.
Try

<%        
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    response.setDateHeader("Expires", "0");
%>

See also this page for cross-browsers information.

Upvotes: 2

Related Questions