HTTP 1.1 etag and last-modified improve PHP Efficiency

Source: Internet
Author: User
Tags http 200

As blogs are prevalent today, some Web applications need to parse a large number of "> RSS feed. How to improve efficiency is a very important issue. In features of magpierss, this article lists the following:"> HTTP conditional getsSave bandwidth and speed up download times with intelligent use of last-modified and etag .. Here etag caught my attention.

What is etag?

By reading RFC 2616, I got an impression of etag:

The etag response-header field provides the current value of the entity tag for the requested variant ...... entity tags are normally "strong validators," but the Protocol provides a mechanic to tag an entity tag as "weak. "One can think of a strong validator as one that changes whenever the bits of an entity changes, while a weak value changes whenever the meaning of an entity changes. alternatively, one can think of a strong validator as part of an identifier for a specific entity, while a weak validator is part of an identifier for a set of semantically equivalent entities.

As we can see from the above, entity tags is essentially a "strong validator", but "> HTTP provides a" weak "mechanism by tagging entity tags (similarContent Verification Code). Although this section is explained in two ways later, it is still a bit obscure. After reading this section, I just got that etag's "E" stands for "entity.

MagpieArticle: HTTP conditional get for RSS hackers, which is much clearer after reading. first, let's talk about "> the basic principle of HTTP conditional gets. It is very simple. That is to say, when retrieving data from the Web server, if the file changes, give me a new file. If the file does not change, you only need to tell the client that there is no change and you do not have to retrieve the file back. this saves a lot of bandwidth and resources.

Etag and last-modified are concepts from "> HTTP 1.0 to"> HTTP 1.1. when we get a file from the Web server, we only need to read the etag and last-modified fields in the HTTP response header, what are the specific content of these two fields? (it may be strange, "> RFC 2616 does not have a specific value for etag.) cache these two values locally, the next time you check whether the file is updated, compare the two values. if there is no change, the server's responseCodeIt is not "> HTTP 200 (OK), but 304.

For example. at present, openrss has subscribed to more than 40 feeds, but the response speed is very good. when using gregarius (lilina also applied etag), it found that almost all the feeds burned by feedburnrer use etag (otherwise it is estimated that the server will be paralyzed, Hoho ). let's test the response of "> HTTP header:

$ Curl-I http://feeds.feedburner.com/dbanotesHTTP/1.1 200 okdate: Tue, 25 Oct 2005 11:34:15 gmtserver: ApacheLast-modified: Tue, 25 Oct 2005 04:30:12 GMTEtag: u4q478bdklqz8ummc8a5afzuhugContent-Type: text/XML; charset = UTF-8 $ curl-I http://feeds.feedburner.com/dbanotesHTTP/1.1 200 okdate: Tue, 25 Oct 2005 11:34:21 gmtserver: ApacheLast-modified: Tue, 25 Oct 2005 04:30:12 GMTEtag: u4q478bdklqz8ummc8a5afzuhugContent-Type: text/XML; charset = UTF-8

During this period, my blog is not updated. Therefore, the values returned by last-modified and etag are the same. In this way, gregarius does not have to be resolved again. greatnews in China is supported."> HTTP conditional getsIs also supported.Gzip/deflate EncodingAnother RSS reading tool popu (Zhou botcom) does not know.

The above are my notes. please correct me if you have any misunderstanding!

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.