Http1.1Etag and Last-Modified improve php efficiency _ PHP Tutorial

Source: Internet
Author: User
Http1.1Etag and Last-Modified improve php efficiency. As blogs are prevalent today, some Web applications need to parse a large number of rssfeeds. how to improve efficiency is a very important issue. in Features of MagpieRSS, this article lists the following:

As blogs are prevalent today, some Web applications need to parse a large number of RSSFeed. how to improve efficiency is a very important issue. in Features of MagpieRSS, the following is an example:HTTPConditional 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 HTTPThe protocol 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.

Magpie mentioned an article on the homepage: HTTP Conditional Get for RSS Hackers, which is much clearer after reading it.The basic principle of Conditional GETs 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 are1.0 to HTTP1.1 Concept. when we get files from the Web server, we only need to read the HTTPThe Etag and Last-Modified fields in the response header can be used. the specific content of these two fields can be ignored (it may be strange, RFC2616 there is no 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 response code of the server is not HTTP200 (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 HTTPResponse of the 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 GMT ETag: 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.HTTPConditional 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!

Today, Blog is prevalent, and some Web applications need to parse a large number of RSS feeds. how to improve efficiency is a very important issue. in Features of MagpieRSS, we listed the following :...

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.