Cache in an HTTP request

Source: Internet
Author: User

An HTTP request goes through the following types of Cache

(In the order from the client to the server)

1. browser-side storage:

    • The local storage function in HTML5 allows you to save data on a browser.
    • Third-party plug-ins such as flash also have similar functions.
    • Javascript saves some data in the current context.

2. Browser file caching

    • In the HTTP protocol, local files are directly used without request server data when the time has not expired (refer to the Cache Control Section in the HTTP protocol)
    • It is often used for caching HTML, JavaScript, CSS, and other files to reduce the number of requests.

3. Http cache 304:

    • In the HTTP protocol, if the server file does not change, the user request data is not returned, but only a 304 response is returned. (For more information, see http protocol)
    • Does not reduce the number of requests, but reduces the response volume
    • Implement caching by controlling the output content of dynamic files (you can take a look at etag and other related content)

4. Server File Type Cache

    • Static HTML files for dynamic pages;
    • Proxy Server, CDN, Etc ..
    • Some infrequently updated data is statically converted into files.
    • Mainly to save server resources, such as CPU

5. Normal memory cache:

    • This is the most frequently used cache.
    • Powerful functions, such as. Net cache class timed data expiration according to time rules, such as cache database data

6. distributed cache

    • For example, memcached, modern applicationProgramThe scale is getting bigger and bigger, so it is inevitable to use such solutions
    • Distributed caching is often implemented through self-splitting programs

7. database cache

    • Most databases load data to the memory to improve performance.

8. Presentation Layer & Dom Cache

    • Buffer HTML fragments on the client and server (only update the parts to be updated, such as many Ajax implementations)
    • For example, the chain expression in jquery (some data shows that the chain expression is faster than 25%)

All of the above aspects can be controlled through development or configuration (some cache types that are not easy to control are not mentioned)

In addition:

    • ManyProgramming LanguagePut the data in static variables and other Members, it is actually a kind of Cache
    • In addition to data and file caching, there are also many caches for the program itself
    • For more information about HTTP cache, see RFC 2616.
    • Many components have built-in cache functions, such as nhib.pdf. if you pay attention to the configuration, you can get a good performance improvement.

Depending on the degree of common use, the development difficulty ranges from easy to complex, and the development priority ranges from high to low.

The recommended sequence is 5> 2> 3> 8> 4.

The server cache is directly stored inCodeMedium Development, low cost, strong functionality

HTTP cache is generally supported by built-in servers (such as IIS and Apache). Of course, it can also be programmed and implemented, which is also recommended.

Local Storage is not widely used. It is widely used in websites with high client requirements.

Solutions such as memcached are required for large-scale websites.

Database cache is a relatively difficult scope to control (it is more effective than optimizing indexes and database design)

Several tools are recommended at the same time.

Fiddler httpwatch is used to track HTTP request details

Dottrace is used to trace the details of. Net code.

We hope that the above content will help you gain some benefits in developing high-performance web applications.

If any omissions or errors exist, please correct them.

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.