Common HTTP headers

Source: Internet
Author: User

1. HTTP request
Protocol name: // host name: Port Number/resource URI

/*******************************
GET/index.html HTTP/1.1
Host: localhost: 8088
Connection: Keep-Alive

******************************/

 

2. request header
Host, request header, standard name Request Host Name, can be IP or domain name, and is mandatory after http1.1. With this request information, you can create a WEB virtual machine on the server to implement multiple WEB Services on one machine
Content-Length, the size of the data bytes of the request and response body
Accept-Encoding, request header, and acceptable text compression algorithms, such as gzip and deflate
Accept-Language, request header, supported Language, client browser settings, such as zh-cn, zh; q = 0.8, en-us; q = 0.5, en; q = 0.3
User-Agent, request header, and browser information, such as: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv: 12.0) Gecko/20100101 Firefox/12.0, if you register for IE, you will also use Mozilla. This is a historical issue. In the early days, WEB servers seemed to have problems. Only Mozilla was supported, and Microsoft IE, as a rising star, could only be disguised as Mozilla.
Cookie, request header, the COOKIE set by the server or client last time, including the domain name (.360buy.com), expiration time, key and value. Most WEB servers add Set-Cookie to the response header during the first access, for example, BAIDUID = 49347814cdbbb4ce65ec50ee4bb65e9a: FG = 1; expires = Wed, 07-Nov-42 07:03:34 GMT; path = /; domain = .baidu.com
A Referer opens a new page from a connection. The request for a new page usually adds this information. Where did the name jump from? The History chain of opening all pages can be mined, analysis of user behavior and CPS sharing

 

 

3. reponse header
Content-Type, response data Type: text/html; charset = gbk
Content-Length, response data body size
Content-Encoding. If it is text or HTML information, the Encoding method is used.
Date, current server Date
Server, Server name
Set-Cookie: this information is contained in the response header when the first access or service is Set as a COOKIE, for example, BAIDUID = 49347814cdbbb4ce65ec50ee4bb65e9a: FG = 1; expires = Wed, 07-Nov-42 07:03:34 GMT /; domain = .baidu.com

 

4. Cache-Control, Expires
Control the two Response Headers in the Cache. If both are in the Response Header, press Cache-Controler to calculate
Cache-Control, which is the response header. value:
Public, which can be used by any login user of the current system
Private, this user logged on to the current system caches
No-cache, no cache
Max-age: specifies the number of seconds for caching. For example, Cache-control: max-age = 5 indicates that the server will not be accessed again within 5 seconds after the webpage is accessed.

 

Expires, which is the response header and is later than Http1.1. It is used to control the cache expiration date like Max-Age.
References: http://bubbyroom.com/tag/cache-control/

5. Last-Modified, If-Modified-Since
Last-Modified: Response Header, marking the Last modification time of this document
If-Modified-Since is the request header, the Last-Modified date of the previous request is returned as a value. If the server determines that the Last-Modified time is the same as that of the server, 304 is returned, the browser uses the local cache for display. It is generally used to save bandwidth and accelerate request and display.

6. ETag + If-Match
The cache policy is also used as a supplement to the above
ETag is the response header. It is defined as a string in http1.1. The specific format is undefined and used to verify the client cache.
If-Match: The request header information. The Etag of the Last request response is carried with the request. The server can handle the request flexibly as a supplement to Cache-Control, Expires, and Last-Modified, cache policies that are not based on time.
Apache sets the Etag value of html to INode + Mtime + Size by default.
For example, Etag "2e681a-6-5d044840" 1
Purpose:
A. Only the modification time is changed, but the content is not modified.
B. The modification is very frequent. It can be Modified thousands of times in one second, but the Cache-Control and Last-Modified values can only be controlled within seconds. This is a further improvement in the Control strength.
C. Some servers cannot accurately obtain the last modification time of the file. For example, all the servers we use are supported, so they are not used much.

 

7. Connection Keep-Alive
The HTTP protocol uses the TCP protocol. Each page resource request is set to a connection. When the TCP three-way handshake of each connection is closed, the four communications and port stranded wait to prevent data packets from being transmitted,
Each TCP is the number of I/O handles to open files, which is strictly limited by Unix/Linux.
A large number of resource files (html, css, javascript, and image) need to be loaded over TCP connections with a large amount of data. To reduce the number of socket connections, KeepAlive is provided, make a tcp connection reusable.
It turns out that using Keep-Alive is faster (but mobile client interface development will disable this attribute ).

8. Range: 10-100
Part of the information, which is often used for resumable download.

9. Return status code
200, return success
501. server content error
304. Use local slow firebug
404, resource not found
Reference: http://www.ganguoyuan.com/03/curl-http_code-%E7%8A%B6%E6%80%81%E7%A0%81-%E6%84%8F%E4%B9%89%E5%8F%8A%E4%BF%A1%E6%81%AF/

 

10. http Protocol monitoring tools:
Firebox: httpfox, live http header, firebug
IE: httpwatch, iehttpheader

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.