Search code examples
htmlbrowser-cacheprefetch

HTML5 cache manifest and prefetching


One thing I'm not fully grasping is if the cache manifest is also acting as a prefetch when it is online for all the files listed.

For example, lets say I'm visiting:

/page1.html

Each of the pages on my site will have the same declaration:

<html manifest="/cache.manifest">

In the cache manifest file, I have:

CACHE MANIFEST
/page2.html
/page3.html
/page4.html

So what will happen is I visit /page1.html first, and when I'm online my browser will know to cache pages 2-4 also. And when I'm disconnected and I visit pages 2-4 everything will load just fine because it was already cached.

QUESTION: If I visit /page1.html, and I'm STILL connected online, and visit /page2.html, will my browser still request /page2.html, or will it not make another request to the server and use what it cached from the /cache.manifest file? Essentially acting like the prefetch link that firefox uses?


Solution

  • Well, the spec says "all files," without any exceptions for html files, so I figure it works for html files just like any other, it gets taken from the cache, not the server. However, I have not done any testing to confirm this. I would do the following:

    Create the following cache manifest file:

    CACHE MANIFEST
    /page1.html
    /page2.html
    /page3.html
    /page4.html
    

    Include it in each of the four cache manifest files. Then:

    1. Visit page1.html
    2. Edit page2.html to make it different than before you visited page1.html
    3. Visit page2.html
    4. See which version you get.

    Make sure you try it out on all browsers. I'll be interested to see your results.