16

I've been looking for a way to cache pages for use only when the user is offline, otherwise download the pages normally. However, once a cache manifest is detected, the browser will only load from those cached pages.

My search landed me on http://whatwg.org. The section about Writing Cache Manifests caught my eye. Here's an excerpt:

A section header

Section headers change the current section. There are four possible section headers:

CACHE:
    Switches to the explicit section. 
FALLBACK:
    Switches to the fallback section. 
NETWORK:
    Switches to the online whitelist section. 
SETTINGS:
    Switches to the settings section.

The first three are well known, but I hadn't heard of the last section header, SETTINGS:. The documentation continues to say this:

Currently only one setting is defined:

The cache mode setting

This consists of the string "prefer-online". It sets the cache mode to prefer-online. (The cache mode defaults to fast.)

This made me wonder if the prefer-online setting was exactly what I was looking for. I was hoping that this setting would tell the browser that it should only load the cached pages if the setting was set to fast, otherwise download the pages if the user is online.

Unfortunately, I can't find any additional information or explanation about this. Has anyone come across any information about the prefer-online setting? Or about the SETTINGS: section in general?

2
  • 1
    Which browsers did you test with the prefer-onlinesetting? For me it worked well with Firefox 14.0.1 and Opera 12.00 but Chrome 21.0.1180.75 and Androids (API Level 13 - emulator) native browser and WebView seems to ignore it. Aug 13, 2012 at 8:12
  • I'm not sure of the versions, I didn't write them down at the time, but I tried it with Chrome and Firefox. I'm glad it's working in newer versions, though.
    – Ryan
    Aug 27, 2012 at 16:25

1 Answer 1

10

prefer-online will go to the server if there is a connection, even if the file is cached. If there is no connection it will use the cache.

fast will use the offline version, even if there is a connection.

Although you can set these preferences, the user agent can still decide what it thinks is best.

6
  • So you're believing just exactly what was mentioned in the question? nice "answer"... Aug 10, 2012 at 6:15
  • 2
    @MarvinEmilBrach: Unless he's actually wrong that's still a valid answer though. Besides that, the NAA flag is not for wrong answers. Aug 10, 2012 at 10:35
  • I have removed the emotive word "believe" from the answer. I hope the new version is more assertive, as it is correct.
    – Fenton
    Aug 10, 2012 at 12:55
  • 2
    This is true for MASTER entities onnly, not for any others.
    – kuncajs
    May 24, 2013 at 14:17
  • @SteveFenton can you include a link that describe setting section Jun 6, 2015 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.