Can the new HTML5 manifest.cache file contain paths to directories?
Asked Answered
R

2

11

When utilizing the HTML5 ability to specify if/how files are cached (in the manifest.cache file), are specifying entire directories possible? Can I place a path to my images directory under the CACHE: section and have it apply to all files in that directory, or do I need to explicitly specify the image files to be cached?

In other words, is this possible?

CACHE MANIFEST

...

CACHE:
images/

... or maybe this?

CACHE MANIFEST

...

CACHE:
images/*

... or do I have to do this:

CACHE MANIFEST

...

CACHE:
images/logo.png
images/image01.jpg
images/image02.jpg
images/image03.jpg
... (etc)
Resistencia answered 31/1, 2011 at 18:24 Comment(1)
The second one works I believe. Take a look at go offline with application cache for further examples.Homemade
L
15

Unfortunately, the third example is the correct one - list every file individually. The html5 doctor article was incorrect at the time the question was posted and has since been amended.
A wildcard * is allowed only in the "online white list" section:

NETWORK:
*

which allows any required files to be downloaded while you are browsing online if not already downloaded (as per normal).
There is also the Fallback section's "page path pattern":

FALLBACK:
/ /offline.html

that kinda works like a wildcard. The initial / will match the path to every page on your site, so any page that is not found in the cache will then use the /offline.html as the replacement fallback. (Note the space between the two slashes.)

Limicoline answered 12/4, 2012 at 18:4 Comment(0)
N
1

I think you could achieve a 'wildcard' by building the .manifest (or .cache in your example) file with the help of a PHP file. This way you could let PHP handle the hassle of maintaining the filenames by scanning directories en echo'ing each filename. Probably best to actually let PHP put a .manifest file on your server, otherwise the offline App could think the manifest file got updated and continually refreshed the cache.

Nimiety answered 16/1, 2013 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.