0

I want to reload the page upon back navigating in IE11 but couldn't make it work. I use JSF, HTML5. First, I open the developer tool, choose Network tab and disable "Always refresh from server".

My first page:

<body>
    <a href="http://google.com">another page</a>
</body>

When I open the page and click on "another page" link and navigate back to the first page. I check on the Network tabs, the status code is 304 which means the first page is read from cache.

On Microsoft reference https://msdn.microsoft.com/library/dn265017(v=vs.85).aspx, it says

In order to be cached, webpages must meet these conditions: Page has no beforeunload event handlers defined

So I define a beforeunload event handler inside the page. Now it becomes:

<body>
   <a href="http://google.com">another page</a>
   <SCRIPT>
      window.onbeforeunload = function() {
        console.log("HI");
      }
   </SCRIPT>
</body>

Now I do the exact steps as above, and during the process I get this log in Console tab:

DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337

That means back caching is disabled on this page, but I still get the 304 status code which means the page is not reloaded from server. (I check by turning off the server).

I also try to prevent caching by adding meta tags as below but it still doesn't help:

<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" />

Could you point out the problem for me?

Ta Ntt
  • 101
  • 4
  • 1
    HTML meta HTTP equiv tags will never work on HTML pages served over HTTP: http://stackoverflow.com/q/49547. Moreover, specifically those ones are **deprecated** in HTML5. – BalusC Apr 06 '16 at 11:00
  • Thank you so much, following the no-cache-control servlet filter works perfectly for me. My concern is that even though **IE11** says that a page with onbeforeunload defined won't be back/forward cached but it still caches anyway. It could be a bug of IE, I guess. – Ta Ntt Apr 07 '16 at 04:12

0 Answers0