Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear browser cache programmatically in jsp?

Tags:

java

jsp

In my web application there is some problem due to browser cache.

How to clear the browser cache when loading my jsp page?

How can i include clear cache code in jsp page?

like image 220
anoop Avatar asked Jul 05 '12 04:07

anoop


2 Answers

You can do this way in your JSP to prevent from caching,not able to clear the cache programatically:

 <% 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  
%>
like image 184
UVM Avatar answered Nov 12 '22 09:11

UVM


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

work perfect in jsp and remember to check session

<%

User u = (User) request.getSession().getAttribute("user");
if (u != null ) {
//show page
}else{
// redirect to login page
}

%>
like image 36
user2633890 Avatar answered Nov 12 '22 08:11

user2633890