HTML5 appcache with .net and IIS8.5

It's becoming increasingly important for web-based applications to be accessible offline. Yes, all browsers can cache pages and resources for long periods if told to do so, but the browser can kick individual items out of the cache at any point to make room for other things. HTML5 addresses some of the annoyances of being offline with the ApplicationCache interface.

Using the cache interface gives your application three advantages:

Offline browsing - users can navigate your full site when they're offline
Speed - resources come straight from disk, no trip to the network.
Resilience - if your site goes down for "maintenance" (as in, someone accidentally breaks everything), your users will get the offline experience

Referencing a manifest file

To enable the application cache for an app, include the manifest attribute on the document's html tag:

'< html xmlns="http://www.w3.org/1999/xhtml" manifest="ccit.appcache" >'

A manifest file must be served with the mime-type text/cache-manifest. You may need to add a custom file type to your web server or .htaccess configuration.

For example, to serve this mime-type in Apache, add this line to your config file:
AddType text/cache-manifest .appcache

In IIS go to MIME and add new MIME type .appcache with type text/cache-manifest . Restart the webserver.


Now create your menifest file as follows:

CACHE MANIFEST
# 2017-02-06 v1.0.1
# Explicitly cached 'master entries'.
#/theme.css
#/logo.gif
#/main.js
/assets/fonts/FontAwesome.otf
/assets/fonts/fontawesome-webfont.woff2
/assets/fonts/fontawesome-webfont.woff
/assets/fonts/fontawesome-webfont.ttf
/assets/fonts/fontawesome-webfont.svg
/assets/js/jquery.min.js
/assets/js/main.js
/assets/js/skel.min.js
/assets/js/util.js
/assets/css/font-awesome.min.css
/assets/css/ie8.css
/assets/css/ie9.css
#assets/css/main.css
NETWORK:
# Resources that require the user to be online.
ccit.appcache
Default.aspx

FALLBACK:
/ offline.html


Check manifest file status at  chrome://appcache-internals/


Comments

Popular Posts