开发者

Unable to disable jsp cache

开发者 https://www.devze.com 2023-03-14 01:18 出处:网络
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\");

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消