3

Since Firefox is prompting the user to store data when using the HTML5 application cache, I want to disable it in Firefox to avoid the prompt notification.

One way to do that is serving two different HTML files: one for Firefox with <html> and one for the other browsers with <html manifest=...>.

But for efficiency purposes I want to serve one single static file.

So how do I disable the application cache while serving a file with <html manifest=...> in Firefox?

Trott
  • 66,479
  • 23
  • 173
  • 212
brillout
  • 7,804
  • 11
  • 72
  • 84
  • There is a dom.storage.enabled setting in about:config that should do what you want. – Marc B Aug 26 '11 at 18:52
  • @Marc: I don't think that he wants to disable it in his personal web browser. – Wladimir Palant Aug 26 '11 at 18:56
  • "one single static file". Since that means the server can't mangle the file, that leaves changing browser settings. – Marc B Aug 26 '11 at 18:58
  • @Marc B: I was speaking from a web developer perspective. Since your setting is a user setting and a global setting I won't be able to change it as a website – brillout Aug 26 '11 at 19:00
  • Then you'd need to do something dynamic on the website. Some browser sniffing and serve up the cache-free version to any browser claiming to be Firefox. – Marc B Aug 26 '11 at 19:03
  • @Marc B: I meant the file serving being static, the solution could be dynamic though. They also may be a static solution, e.g. if Firefox doesn't handle some cache manifest syntax leading Firefox to drop the caching – brillout Aug 26 '11 at 19:14

2 Answers2

5

The manifest attribute isn't checked until the page is loaded. Meaning that you can remove it while the page is loading and the prompt won't appear. Like this:

<script type="text/javascript">
  if (window.navigator.product == "Gecko")
    document.documentElement.removeAttribute("manifest");
</script>

Which of course assumes that all Gecko browsers need to be banned for all eternity because of this prompt. Definitely not nice, particularly because the prompt might disappear at some point in future. But I don't see a proper way to detect whether a browser will prompt the user about storing the web application for offline use.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
  • this works. thousand thanks. I was subconsciously falsely assuming that it would be checked before the loading of the page:). Yeah I would love to enable appCache for Firefox but to me the prompt is a no go which btw from my perspective is kind of a flaw of Firefox – brillout Aug 26 '11 at 19:30
  • window.navigator.product is "Gecko" in Safari and Chrome too! Also the fact that this works seems to be an accident, against HTML5 spec, which says that "Application cache selection happens in the HTML parser." (http://www.w3.org/TR/html5/browsers.html#read-html) – natevw Dec 31 '12 at 17:49
2

Use an iframe to install the applicationCache; that way you can prompt a user with a button, and load the iframe once they click on that button.

Downchuck
  • 21
  • 1