HTML 5 offline storage cache manifest not working
Asked Answered
D

5

7

I'm trying to get HTML5 offline storage working in a basic way. I read the information on DiveIntoHTML5 and it seems to make sense, but it just doesn't seem to be working for me. I wondered if someone could help me to debug this.

Basically I've set up a home page for the application, index.htm. So my application is on the web at http://www.mydomain.com/online/index.htm. Users will visit this page, where they'll ordinaraily do all of their stuff day-to-day. Visiting this URL will create a bunch of cached files so they can then visit http://www.mydomain.com/offline and view a working version of the application when they're offline.

The top few lines of code in the online homepage are:

<!DOCTYPE html>
<html manifest="cache.manifest">
<head>
   ...etc

I've generated a plain text file called 'cache.txt' and added the following content to it in Notepad:

CACHE MANIFEST
http://www.mydomain.com/offline/scripts/jquery-1.6.3.min.js
http://www.mydomain.com/offline/scripts/jquery-ui-1.8.16.custom.min.js
http://www.mydomain.com/offline/scripts/modernizr.min.js
http://www.mydomain.com/offline/scripts/json2.min.js
http://www.mydomain.com/offline/scripts/jquery.deserialize.js
http://www.mydomain.com/offline/scripts/jquery.cookie.js
http://www.mydomain.com/offline/scripts/main.js
http://www.mydomain.com/offline/css/main.css
http://www.mydomain.com/offline/css/structure-details.css
http://www.mydomain.com/offline/css/ui-lightness/jquery-ui-1.8.16.custom.css
http://www.mydomain.com/img/header.gif
http://www.mydomain.com/offline/img/bg.png
http://www.mydomain.com/offline/img/header_riser.gif
http://www.mydomain.com/offline/img/logo.png
http://www.mydomain.com/offline/img/offline.png
http://www.mydomain.com/offline/index.htm

I've then renamed this file to 'cache.manifest' and uploaded it to the root of the online application (at the same level as my home-page) so that it's accessible at http://www.mydomain.com/online/cache.manifest.

The hosting company have supposedly added the content type of 'text/cache-manifest' to all files with the extension of .manifest in IIS. I think this is working because when I view the file in Firefox at http://www.mydomain.com/online/cache.manifest Firebug tells me the content type is:

Content-Type    cache-manifest

Or should this be returning 'text/cache-manifest'? Perhaps this is the problem?

When I view the offline storage folder on my system (C:\Users\Me\AppData\Local\Mozilla\Firefox\Profiles\b12u6xza.default there's nothing in there related to this domain at all.

Can anyone suggest what might be going wrong - as I'm a little stumped?

Depreciation answered 4/10, 2011 at 10:21 Comment(0)
K
1

First of all, the specification have changed, you should now use .appcache as manifest extension.

Second, the mime type should be defined as you say text/cache-manifest. I'm not really related to IIS but seems like there's two ways to add this MIME type , either trough IIS administration UI or via web.config file

Also, I would recommend you testing this with Google Chrome, since its console show all the manifest parsing data and errors, including when the manifest MIME type is not being correctly recognized.

Keane answered 12/1, 2012 at 17:33 Comment(1)
the spec says the file can have any extensionInequity
B
1

There are some issues you have to be care about:

  1. Chrome (And I guess that all the browsers at last) only handles the cache file over secure requests. If your request is not secure, your cache won't be executed.
  2. Mobile browsers (At least, the devices I could test), doesn't care about secure or unsecure requests. But I'd prefer to be ready for the politics change.
  3. I was breaking my head trying to understand why in Android my file worked fine and in iOS it was failing, and the reason was that I was running my browser in incognito mode. iOS in incognito mode can't cache the page, and you get error.

If I find more issues, I'll write it down.

Regards.

Bungle answered 16/3, 2018 at 21:6 Comment(2)
Your answer ended my search. If request not secure, your cache won't be executed! I was breaking my head trying to understand why Manifest not working on apache.Antisepsis
No, I tested it, it has nothing to do with secure connection. This should work fine locally as well without any httpsOedipus
O
1

I spend a lot of time on this (on my own problem), offline cache was not working. Did everything possible I could do, changed cache file name, added handler via htaccess, uploaded the file from local to live server, still the same problem. Finally got some help from this question myself.

I tested it in safari and it was working fine. The problem was Chrome browser. I also tried https as another user suggested, that also did not fix the problem. So may be there is an extension in chrome that is forbidding it from using the cache file. Before troubleshooting your problem first test it in standard browsers Safari, FireFox, IE, Opera. Do not test in non-standard browsers such as Brave, it did not work in it.

Officially from google

Which confirms deprecation in Ver 61 and onward. I am running 80.

Chrome support for applicationcache and manifest for offline html5 application.

Application Cache / Offline Application / Manifest Cache.

Aware that applicationcache has been deprecated, but whilst replacement (service workers) not ratified have yet to replace in legacy systems we have.

However, recent browser update seems to have disabled offline functionality on HTTPS site. Our manifest files are now ignored and chrome dinosaur displayed instead.

On checking back through browsers seems this is common from Chrome 61 and newer however it only seems to have manifested recently.

Chrome issue? or combination of Chrome and underlying OS? We have android/windows both showing same problem from 61 onwards.

Note : HTML5 Cache is being deprecated

All browsers are going to drop this feature, I noticed they are not working in any of the latest browsers. This MDN Mozilla strongly advises against it and not to use it.

Oedipus answered 8/3, 2020 at 21:54 Comment(0)
T
0

try to add these lines in httpd.conf ..this might help you

AddType text/cache-manifest .manifest

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/cache-manifest "access plus 0 seconds"
</IfModule>
Toffey answered 4/10, 2011 at 10:27 Comment(1)
Is this for Apache, or IIS? My environment is Windows/IIS.Depreciation
M
0

You'd better test using chrome's console !(you can't see these in chrome's network)

My example(visit:www.mustrank.com/views/1.php ).

Look at chrome's console output below,manifest file "website.appcache" is created first,and then sources "1.html" and "main.css" are downloaded

[Creating Application Cache with manifest www.mustrank.com/views/website.appcache 1.php:1

Application Cache Checking event 1.php:1

Application Cache Downloading event 1.php:1

Application Cache Progress event (0 of 2) www.mustrank.com/views/1.html 1.php:1

Application Cache Progress event (1 of 2) www.mustrank.com/css/main.css 1.php:1

Application Cache Progress event (2 of 2) 1.php:1

Application Cache Cached event ]

Motteo answered 21/4, 2014 at 3:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.