HTML and CSS Reference
In-Depth Information
Listing 8-2. Implicit CACHE Section
CACHE MANIFEST
Clock.aspx
Images/HTML5.png
StyleSheet.css
Scripts/jquery-1.7.2.min.js
The cache manifest file written so far conveys that the four files specified in the CACHE section are to be
downloaded to the local cache.
n Note: The Clock application is an ASP.NET Web Forms application; if you developed it as an MVC application,
then instead of Clock.aspx you would specify a controller action that renders the respective view (for example,
Home/Index ).
The NETWORK Section of the Cache Manifest
The CACHE section specifies what files the browser should cache for offline usage. The NETWORK section does
exactly the opposite: it lists files that should not be cached. Suppose your application displays
advertisements in addition to page content. They most likely come from an ad engine that keeps track of
ad impressions and clicks. Obviously, such ads can't be stored offline. If your offline application uses such
resources, they should be listed in the NETWORK section.
Listing 8-3 shows the Ads.js file listed in the NETWORK section.
Listing 8-3. NETWORK Section of the Cache Manifest File
CACHE MANIFEST
CACHE:
...
NETWORK:
Scripts/Ads.js
This way, Ads.js is never cached in an offline cache. Instead, it's always accessed over the network.
In a big application, there may be many candidates for the NETWORK section. At times you may not even
know in advance that a resource needs to come over the network. In such cases, you can use the * wildcard
character to inform the browser that all files not listed in the CACHE section should be accessed over a
network. You use the * character like this:
NETWORK:
*
The NETWORK section is also useful when you're working with resources (images, scripts, and so on) that
are hosted on a different server and referred to by your application. For example, you might be using
images and script files hosted by a CDN rather than including them in your application. If you don't
include these external resources in the NETWORK section (either explicitly or by using the * wildcard), then,
strangely enough, your application won't load them when you're online.
 
 
Search WWH ::




Custom Search