Search code examples
htmlcache-manifesthtml5-appcache

HTML5 appCache manifest referencing a directory's default document


Throughout a jQuery mobile site I am working on I have anchor tags that refer to urls in the following manner:

  • "/directory/"
  • "/directory/subdirectory/"

which are of course referencing:

  • "/directory/index.html"
  • "/directory/subdirectory/index.html"

So in my manifest file do I need to reference the "root" version at all? For example

CACHE MANIFEST

CACHE:
/directory/
/directory/index.html
/directory/subdirectory/
/directory/subdirectory/index.html

NETWORK:
*

FALLBACK:
/ /offline.html

or:

CACHE MANIFEST

CACHE:
/directory/index.html
/directory/subdirectory/index.html

NETWORK:
*

FALLBACK:
/ /offline.html

does it automatically know that "/directory/" is equivalent to "/directory/index.html", etc? seems like it wouldn't.


Solution

  • The cache is keyed according to URL. Whatever file the browser gets when it accesses /directory/ is whatever file it will cache for that URL. However it doesn't know automatically that /directory/index.html is equivalent to /directory/, that is something only your server could know. If you list both URLs in the manifest then both URLs will be cached, even though they turn out to be identical.