I am developing a Java EE web application using Struts. The problem is with Internet Explorer caching. If an user logs out he can access some pages because they are cached and no request is made. If I hit refresh it works fine. Also if an user goes to login page again it won't redirect him because that page is also cached.
Two solutions come to my mind:
<meta>
tags at each page.Which one should I do?
Navigate to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings registry subkey. From the Edit menu, select New, DWORD Value. Enter a name of DisableCachingOfSSLPages, then press Enter. Double-click the new value, set it to 1 to disable caching of SSL pages, then click OK.
Every time a user loads a website page, their browser downloads the page's data to show it. Just like website servers, browsers cache most content on a page to shorten load times. So, the next time that user loads the page, most of the content is ready to go without needing to download additional data.
Rather set the following headers on the HttpServletResponse
of the page(s) in question so that you don't need to copypaste it over all pages manually:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
This is equivalent to setting the following meta headers in the page(s) manually:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
Also see this answer. Don't forget to clear browser cache before testing ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With