<%response.addHeader("Pragma", "No-cache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", -1);
%>
what is the purpose of this code ...
plz explain me in details ....
thanx in advance .....
Hello,
At the top of every JSP the above header attributes are used to prevent caching.
Now I don't know in depth about 'Caching' but whatever little I know I'll share it with you, for the details we'll have to wait for an expert opinion :)
Well,
Http headers used for cache control to prevent the web pages from being cached by the browser and proxy server.
response.setHeader("Cache-Control","no-cache"); //prevents disk caching (HTTP 1.1)
response.setHeader("Pragma","no-cache"); //prevents disk caching (HTTP 1.0)
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
I'm not really sure about response.addDateHeader("Expires", -1);
I think its to be used for web pages which have information subject to change promptly, such pages do remain in the disk cache of the IE to be used when the user hits back/forward but when the user actually sends a request for such a page the browser fetches the updated version from the web server.