12.07.2015 Views

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5 CREATING OFFLINE WEB APPSFigure 5-4. Linking to the news.html pageBecause it is in the NETWORK section, the news.html file is never added to the application cache. WhenI click the News button, the browser acts as it would <strong>for</strong> regular content. It contacts the server, gets theresources, and adds them to the regular (nonapplication) cache, be<strong>for</strong>e showing them to the user. I canmake changes to the news.html file, and they will be displayed to the user even when the applicationcache hasn’t been updated.When the browser goes offline, there is no way to get hold of the content that is not in theapplication cache. This is where the FALLBACK entries come in. The <strong>for</strong>mat of these entries is differentfrom the others.• Caution Browsers take different views about what being offline means. I explain more about this in the“Monitoring Offline Status” section later in this chapter.The first part specifies a prefix <strong>for</strong> resources, and the second part specifies a file to use when aresource that matches the prefix is requested while the browser is offline. So, in Listing 5-7, I have set themanifest so that any request to any URL (represented by /) should be given the file offline.html instead.124www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!