This is my hello-world application I just wrote.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); //Line1
// response.setHeader("Content-Type", "text/html"); # Line-AAA
PrintWriter out = response.getWriter();
//out.print("Good days are here :)");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
// out.println("<meta http-equiv=Content-Type content=text/html;charset=ISO-8859-1/>");
out.println("<title>servlet demo");
out.println("</title>");
out.println("</head>");
out.println("<body>Helloworld");
out.println("</body>");
out.println("</html>");
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT"); //Line2
}
Here initially I hadn't written Line-AAA and hence the webpage was not getting displayed properly as is obvious and later I added the line and everything worked perfectly.
But later i tried commenting out #Line-AAA and found that it has no effect even after server restart. Searching on stackoverflow i found two solutionsto disable caching in Line1 and Line2 ,but both doesn't seem to work. Page is getting displayed properly even after commenting out Line-AAA.
It apparently doesn't create any problem for me at the moment, but I am curious to know how to properly stop this caching.
Thanks in Advance