Search code examples
htmlcachinghtml5-appcache

Why doesn't appcache's prefer-online work?


I am creating a simple admin application which have the following requirements:

  • If user is online, fetch latest code
  • Else, use cached code

Now, it appears that appcache always serves the assets from cache, regardless of online/offline connection. Why is that?

Here is my manifest file:

CACHE MANIFEST
# 102

CACHE:
/intake

SETTINGS:
prefer-online

And here is my html:

<!DOCTYPE html>
<html manifest="intake.appcache">
<head>

</head>
<body>
  Something, Anything!
</body>
</html>

How can I get appcache to not cache the resources when an internet connection is available?


Solution

  • Chrome ignores prefer-online or at least it used to. Firefox honors it, or at least it used to. So test it with Firefox.

    Generally, do not rely on prefer-online as the user agent can choose to ignore it. Think of it more as advisory than compulsory.