質問

Ok here is my manifest file below.

CACHE MANIFEST
#r3

NETWORK:
*

CACHE:
/js/jquery.maskedinput.js
/js/less-1.5.0.min.js
/css/styles.less
/css/images/ui-bg_inset-hard_100_fcfdfd_1x100.png
/css/images/ui-bg_glass_45_0078ae_1x400.png 
/css/images/ui-icons_e0fdff_256x240.png
/css/images/ui-icons_0078ae_256x240.png  
/css/images/ui-icons_056b93_256x240.png
/css/images/ui-bg_gloss-wave_75_2191c0_500x100.png
/images/logo.png
http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js

FALLBACK:
/ /offline.php

Inside the file index.php on the html tag I have the following

<html manifest="/cache.manifest">

The cache indeed works, but works too well. I did not tell it in the file that I wanted index.php to be cached but by default it appears to assume you want to cache the file it was called in.

For my program I DON'T want to don't want to do this. I only want it to cache the other resources to help on bandwidth for mobile devices and then I have a fallback page for when there is no internet connection.

Right now it's always using the cache version of index.php therefore visitors to my page will never see the offline.php since it cached it.

How do I prevent the file from assuming it wants to cache the file the manifest was declared from? (or in other words index.php in my example).

役に立ちましたか?

解決 2

I found a solution that works pretty well (My HTML5 Application Cache Manifest is caching everything), it was listed here.

It talks about using an iFrame. By putting the html cache command in the iframe and just hiding the iframe on the index.php page I am able to cache all the other files and even create the fallback file correctly. It's kind of a hack but it gets the job done :).

他のヒント

You need to rethink the app flow. How will the browser initiate the offline version of your app in the first place if the landing page doesn't load? (in case of offline system). When you go offline, the user needs to point to a page that's offline. If the page is not offline then the browser will never read the manifest file and will hence never reach the fallback option in the manifest.

And a side note: the .manifest extension is out of date. Use the .appcache extension along with proper header from the server.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top