Firefox 3 Caches window.location.reload() on localhost

This just cost me hours of grief this morning. The standard way to reload a page in JavaScript is to call window.location.reload(). It turns out that there is a boolean parameter to this method that indicates whether a new HTTP GET request should always be issued; if not, the browser may use a cached version of the page. On Guise this shouldn't matter, because Guise always issues a Pragma: no-cache header, which Firefox has always honored before. But it appears that Firefox 3.0.1 ignores the no-cache command and uses the cached version when reloading the page instead of issuing a new HTTP GET. This only seems to happen when the content is being served from localhost.

If you go to Marmox, which runs on Guise, and log in to or out of your account, Guise will ask the browser to reload the page because your permissions may have changed based upon the user you are logged in as. Guise sends a message to the browser to issue a window.location.reload(), and this has always worked just fine. This morning, though, this caused my browser to go into an endless loop of reloading the page while testing a new Marmox feature on localhost using Firefox 3. Strangely, the public version of Marox on the web didn't exhibit this problem. IE7 didn't show the problem on the web or on localhost. And even more strange, Firefox 3 didn't show the problem when accessing local content when I had updated my local DNS to map the local content to a non-localhost URL.

The problem occurred because Firefox is ignorring the no-cache pragma and simply loading the content it already had. Guise never gets a fresh HTTP GET from the browser, so it still thinks that the component tree is dirty, and keeps telling the browser to reload the page; this causes an endless cycle of "reloads" that never talk to the server. Changing the reload command to window.location.reload(true) as the Mozilla documentation indicates solves the problem. But this shouldn't have been needed, as there shouldn't have been any cached information to reload if Firefox had honored the no-cache header. This, along with the funny business only occurring on localhost and only on Firefox 3, leads me to think this is a Firefox bug.

Update 2008-08-23

This issue may have been the result of a bug in Firebug, the Firefox debugger add-on, not Firefox. See the following bug reports: