Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 352
adam Avatar asked Oct 25 '22 10:10

adam


2 Answers

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.

like image 167
Gaurav Avatar answered Oct 27 '22 11:10

Gaurav


When we use cache manifest it takes the files from the cache each time you load the page. There is a solution for this.

You have to change the version number in the manifest file, If at all you have done any changes to the HTML files. so that your manifest pulls in the latest version of the HTML from the server and Stores it in Cache.

CACHE MANIFEST

#v01
/page1.html
/page2.html
/page3.html
/page4.html

You can just Increment the V01 to 02,03... So on, this will ensure your cache will have latest version of html pages

like image 42
Veerendra Prabhu Avatar answered Oct 27 '22 09:10

Veerendra Prabhu