Offline not working in mobile Safari with cache manifest
I'm working on a mobile site for the iphone. I've added a cache manifest and loaded it with a list of resources needed for offline capability. The manifest file has the correct content type.开发者_运维问答 If you view the response header for the file, the content type is text/cache-manifest. The manifest file is here:
http://hoodisgood.clientsit.es/cache.manifest
The site is viewable here (you'll need to take a look on your iphone (or simulator) or on Safari with user agent set to the iphone.
http://hoodisgood.clientsit.es/
After viewing the site and bookmarking it to the home screen, I set my iphone to airplane mode and when I try to view the site, I can't. I get an alert that it can't open because it's not connected to the internet. I've specified all the files I need for offline operation in the cache manifest file.
Also, correct me if I'm wrong, but with a cache manifest, shouldn't the browser read from the cached source even when the device is online? When I view the site, photos I haven't seen are loaded from the server, as it should be. When I close and reopen, previously viewed images are still loading from the server.
Am I doing something wrong? I checked and re-checked, everything seems to be correct, just not sure why it's not working.
Thanks.
I did notice that your tag did not reference the manifest.
<html manifest="cache.manifest">
Additionally, you need to ensure that the manifest file uses the "text/cache-manifest" mime type.
Also make sure that the manifest has UTF-8 encoding, and not some encoding that the browser has a hard time understanding.
Also I can recommend that you load the site in Chrome. If you check the developer log in Chrome, Chrome will write very helpfull error messages that will guide you to where the problem lies.
I did notice that your tag did not reference the manifest.
<html manifest="cache.manifest">
Additionally, you need to ensure that the manifest file uses the "text/cache-manifest" mime type.
I had a similar problem:
Try referencing absolute paths in your manifest file. This did the trick for me and I as well was using a sub domain.
Also enable your developer console in Safari and add the following JS
function logEvent(event) {
console.log(event.type);
}
window.applicationCache.addEventListener('checking', logEvent, false);
window.applicationCache.addEventListener('noupdate', logEvent, false);
window.applicationCache.addEventListener('downloading', logEvent, false);
window.applicationCache.addEventListener('cached', logEvent, false);
window.applicationCache.addEventListener('updateready', logEvent, false);
window.applicationCache.addEventListener('obsolete', logEvent, false);
window.applicationCache.addEventListener('error', logEvent, false);
Like this you can check what happens in regards to your cache manifest in the browser and learn if an error occurs.
精彩评论