Caching with HTML5 cache manifest
In this recipe, we will learn how to use the HTML5 manifest file in order to store JavaScript and CSS files in the cache browser, along with images.
Getting ready
To test the HTML5 cache manifest file, we just need to create an empty web application. To add it a manifest file at the root of the application, some static files to put in cache and a HTML5 compliant browser.
How to do it...
We'll add the manifest file to enable the cache on the client side, and configure which files will be cached and which files will not.
Let's start by including the manifest file with the relative path as follows:
<!DOCTYPE html> <html manifest="mySite.appcache">
Or with an absolute path:
<html manifest="http://www.mywebsite.com/mySite.appcache"
First of all, let's analyze the anatomy of a cache manifest file:
CACHE MANIFEST # version 1.0
- CACHE:
/Content/Styles/Site.css /Content/Scripts/Site.js http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.2.0.js
- NETWORK:
/Login/...