HTML and CSS Reference
In-Depth Information
stock quote information. Such web applications aren't good candidates to be implemented as offline
applications.
Now, consider an online game. Assume that once downloaded, this game runs in a browser and needs
no data from the server. The data used by the game is created and consumed on the client side. In such a
case, the application doesn't depend on live data from the server and hence can be developed as an offline
application.
Another important consideration is network downtime. Consider a web application that is used by
sales executives. These sales executives are constantly travelling as part of their work and use the
application on their laptops or mobile devices through wireless Internet connectivity. It's possible that they
may not have Internet connectivity at all times; for example, they may travel to a remote location that is
out of the coverage range of the wireless Internet service provider. Unavailability of network connectivity
can hamper their work, so it makes sense to develop an offline application. On the other hand, network
downtime may not make much difference to a web application used by operators for certain routine tasks,
so there is no need to make it available as an offline application.
n Note The term offline application doesn't necessarily indicate that all of a web site's pages work offline. A web
site can have some pages that require network access to function and other pages that work offline. Ofline
application refers to the latter type of web pages.
HTTP Caching and Offline Applications
Before you delve into the details of offline applications, it's worthwhile to understand that they aren't same
as traditional HTTP caching. Caching web resources such as web pages, images, style sheets, and
JavaScript script files isn't a new invention. Browsers have been using these standard HTTP caching
techniques for years. Whenever you access a web page, the browser downloads the page and its associated
resources, such as images and style sheets, and stores them in a cache. This cache is maintained on the
individual client machine. Browsers use this cache for the sake of efficiency and performance. Suppose, for
example, that you're developing web pages that use the jQuery library. You refer to the jQuery library from
the Microsoft Ajax Content Delivery Network (CDN) in all your web pages. If the browser already has the
same version of the jQuery library in its cache, there is no need to download it again from the CDN. The
same is true for images and style sheets.
Most of the time, the browser uses traditional HTTP caching behind the scenes. If you wish to check
whether a browser has stored files in the local cache, you can test the behavior using the browser's offline
mode. Almost all browsers provide an option to work offline. For example, Figure 8-1 shows Firefox's Work
Offline menu option.
If you select this menu option, Firefox doesn't fetch pages from the server. Instead, it uses pages from
the local cache if they already exist; otherwise it gives an error message.
The Work Offline menu option relies on the standard HTTP caching mentioned earlier. Usually you
don't need to write any code on the server to enable this default behavior. If you wish to fine-tune or
prohibit this behavior, you can do so using cache-control headers or IIS Manager.
At first glance, traditional HTTP caching may resemble the offline application caching introduced by
HTML5. However, there are significant differences between them:
• Traditional HTTP caching doesn't need any code or coniguration from your side
unless you wish to alter the default browser behavior. On the other hand, HTML5
offline applications need certain explicit steps from your side.
 
 
Search WWH ::




Custom Search