Unable to disable jsp cache
I don't want the browser to cache a specified jsp, so I used the code below in my jsp:
<%
response.setHeader("Pragma", "No-cache");
response.setHe开发者_Go百科ader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
However, it doesn't work. Everytime I press the back button, the browser shows the cached page without refreshing.
Does the position of the code in the jsp matter? How to disable the cache?
A typo? Pramga
instead of Pragma? Try.
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setDateHeader("Expires", -1);
%>
EDIT: see this question How to control web page caching, across all browsers?
精彩评论