Friday, April 20, 2012

HTML5, Offline, AppCache, .cache = text/cahce-manifest


Hi,

Since I started on HTML5, metro and win8. The interesting things are , IndexDB, offline etc. sadly I couldn't find end-end simple how to get offline working. Below I will explain the simplest How to -

1.      Create asp.net site. Simple site given by Visual Studio.

2.      Think about the resource you want to cache, since this is simplest; I limited myself to cache one image file.

3.      Create a web application in IIS and set virtual directory.

For this web application set the MIME type

            File type = .cache

            Map to – text/cache-manifest

4.      Go to page where is defined.

5.      Modify this with  

6.      Create a file give the same name as defined in manifest=. So I am giving it simple.cache

Simple.cache should look like –



CACHE MANIFEST

CACHE:

<> (with extension and relatives ness>>



Since my cache file is simple.cache, and image file I plan to cache is “mylogo.png” (this is stored in root location for site) so the overall file is



CACHE MANIFEST

CACHE:

mylogo.png



Now run your site. Since the server is available it will run without any problem.

Now stop IIS and rerun site. This time the UI is different as it is coming under offline capability.



Now if you are starting IIS again and want to see original site delete cache from bowser setting. Without this, cached version will be displayed for this simple site.



Enjoy!!




No comments:

Post a Comment