3

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.

Matt
  • 328
  • 3
  • 9

1 Answers1

6

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.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • That is what I assumed. But what confuses me is the FALLBACK behaves differently. / /offline.html acts as a wild card basically. any file it doesn't find gets that offline page, not just the "/" root path. "/404.html", "/anyurl" all get the offline page. – Matt Dec 14 '11 at 22:32
  • 2
    @Matt Because the fallback is not something which is downloaded, it's a pattern to be matched. – robertc Dec 14 '11 at 22:46