[Online Application of HTML5] How to create websites with zero requests and no traffic?

Source: Internet
Author: User
Navigation

[New tag layout for HTML5] layout my blog page with HTML5!

[Form tag of HTML5 preliminary study] Release form verification, add file upload, and integrate drag-and-drop

[HTML5 preliminary study: Drawing Images (I)] view the Canvas Element leading the next generation of web pages

[Image Rendering in HTML5 (bottom)] Let's look at the Canvas Element to lead the next generation of web pages.

[Multimedia element of HTML5 preliminary study] Who is the king of HTML5 and Flash video playback?

[Study of HTML5 Local Storage] If there is no database...

[Online Application of HTML5] How to create websites with zero requests and no traffic?

[Communication API of HTML5 preliminary study] The Cross-origin threshold is no longer high, and data push is not a dream

[HTML5 preliminary study: Web workers] web pages can also be Multithreading

[Geolocation API of HTML5 preliminary study] Let's go back to geographic information

 

About earthquakes

Unfortunately, a magnitude 7 earthquake occurred in ya'an today. I am in Chengdu, and the earthquake is very strong... At around AM, I woke up wearing my underpants and met my sister-in-law (my girlfriend was on a business trip ).

So I held her in my arms with joy and walked onto the balcony. My sister-in-law was amazed, and I was a little uneasy. I felt the shock of nature !!! Although with beautiful people, I still cannot help trembling.

About 30 seconds after the earthquake ended, I opened my sister-in-law and went back to bed. I wanted to continue sleeping, but after a moment, I moved to bed, I can't tell whether I'm shaking or the earth is shaking ......

I don't know when I started to become a very real person. Today I have never gone out... Even when an earthquake occurred, I didn't go downstairs .... Okay, I'm so convinced.

Finally, we hope that the earthquake will soon pass, and we will experience the Wenchuan earthquake. We have a deep understanding of the damage and anxiety caused by the earthquake, and hope that the loss of the ya'an compatriots will be reduced, the efforts of many people in this earthquake will be in vain!

Preface

Today, web applications are already very complex and will become more and more complex in the future. However, he has a fatal weakness that cannot be separated from Internet connections. Therefore, an API is added to HTML,

It uses a local storage mechanism to solve this problem and pave the way for offline web applications.

Local cache in browser cache
The local cache serves the entire web application.
Browser cache only applies to a single web page Service

Any webpage has a webpage Cache
The local cache only caches the pages you specified.

The webpage cache is unreliable and insecure, because we do not know which pages and resources are cached on the website.
Local cache can control the content to be cached
Manifest File

The local cache of Web applications is managed by manifest files on each page. manifest is a simple text, lists the names and paths of files to be cached that do not need to be cached.

You can define manifestor for each page. For example, we set hello.htm:

CACHE MANIFESTCACHE:other.htmlhellow.jsimages/myphoto.jpgNETWORK:http://LuLinniu/NotOfflineNotOffline.asp*FALLBACK:online.js locale.jsCACHE:newhellow.htmlnewhellow.js

In the manifest file, the first line must be the cache manifest to inform the browser of the text, that is, to set the resource files in the local cache.
When running an offline web application, you must configure the server to support the MIME type text/cache-manifest.

When specifying file source files, you can divide resource files into three types: cache, network, and fallback.

Specify the resource files to be cached locally in the cache category. When you specify the resource files to be cached locally for a page, you do not need to specify the page itself in the cache category,
If a page has a manifest file, the browser automatically caches the page locally. The Network Class explicitly specifies the resource files that are not cached. These files can be accessed only by establishing a server link, in this example, the wildcard * is used to indicate that two resource files are specified in each row of the fallback category without any record. The first resource file is the resource file used for online access, the second is the local cache file that cannot be accessed online.
Interaction process between browser and Server

When using offline Web applications for work, it is necessary to understand the interaction process between the browser and the server:

For example, for an http: // listener, the process for the first visit is as follows: 1. the browser requests the url2 server to return to the index.htm homepage 3, request all resource files on the page 4 the server returns the resource file 5 the browser processes the manifest file and requests the files to be cached in the manifest, even if the request has been made, 6 more servers will be requested to return the files to be cached. 7 The browser updates the local cache and saves the files to the resource, and trigger an event to notify the local cache update to open the URL of the url1 request again. 2 The browser finds that the page is cached, therefore, the local cache file 3 is used to parse the file 4 browser requests the manifest File 5 server to return 304, notifying the manifest file not to change (if changed, it will be different)
Applicationcache object

This object represents the local cache, which can be used to notify the user that the local cache has been updated, or to manually update the local cache.

When the browser updates the local cache and loads the new resource file, the updateready event of the applicationcache object is triggered, notifying the local cache that it has been modified, and then prompting the user to manually refresh the page.

Swapcache

The swapcache method is used to manually update the local cache. It can only be called when the updateready event of the applicationcache object is triggered,

This method can be used to manually cache updates when resource files change.

Applicationcache object event

......

Conclusion

I don't know whether it is the cause of the earthquake or why I didn't understand the knowledge points in this chapter. Today, I have no passion to do things ..... Now.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.