Home  >  Article  >  Backend Development  >  Detailed explanation of php file header information

Detailed explanation of php file header information

WBOY
WBOYOriginal
2016-07-25 08:52:111743browse
The detailed introduction to the header information of PHP files is the most detailed one I have ever seen in Programmer’s Home. Friends in need should not miss such a good article.

php file header informationdetailed explanation.

1. Accept: Tell the WEB server what media type it accepts, */* means any type, type/* means all subtypes under this type, type/sub-type.

2. Accept-Charset: The browser declares the character set it receives. Accept-Encoding: The browser declares the encoding method it receives, usually specifying the compression method, whether it supports compression, and what compression methods it supports (gzip, deflate) Accept-Language: The browser declares the difference between the language and character set it receives: Chinese is a language, and Chinese has multiple character sets, such as big5, gb2312, gbk, etc.

3. Accept-Ranges: The WEB server indicates whether it accepts a request to obtain a part of one of its entities (such as a part of a file). bytes: indicates acceptance, none: indicates not acceptance.

4. Age: When the proxy server responds to a request with its own cached entity, this header is used to indicate how long it has been since the entity was generated.

5. Authorization: When the client receives the WWW-Authenticate response from the WEB server, it uses this header to respond to its own authentication information to the WEB server.

6. Cache-Control: Request: no-cache (do not cache the entity, request to get it from the WEB server now) max-age: (Only accept objects whose Age value is less than max-age value and have no expired objects) max-stale: (Objects from the past can be accepted, but the expiration time must be less than the max-stale value) min-fresh: (accept cache objects whose fresh lifetime is greater than the sum of their current Age and min-fresh values) Response: public (can respond to any user with Cached content) private (cached content can only be used in response to the user who previously requested the content) no-cache (can be cached, but can only be returned to the client after verifying its validity with the WEB server) max-age: (expiration time of the object contained in this response) ALL: no-store (no caching allowed)

7. Connection: Request: close (tell the WEB server or proxy server to disconnect after completing the response to this request, and do not wait for subsequent requests for this connection). keepalive (tell the WEB server or proxy server to keep the connection after completing the response to this request and wait for subsequent requests for this connection). Response: close (the connection has been closed). keepalive (the connection is maintained, waiting for subsequent requests for this connection). Keep-Alive: If the browser requests a keep-alive connection, this header indicates how long (in seconds) the WEB server is expected to keep the connection. For example: Keep-Alive: 300

8. Content-Encoding: The WEB server indicates what compression method (gzip, deflate) it uses to compress the objects in the response. For example: Content-Encoding: gzip Content-Language: The WEB server tells the browser the language of the object it responds to. Content-Length: The WEB server tells the browser the length of the object it responds to. For example: Content-Length: 26012 Content-Range: The WEB server indicates which part of the entire object the partial object contained in the response is. For example: Content-Range: bytes 21010-47021/47022 Content-Type: The WEB server tells the browser the type of object it responds to. For example: Content-Type: application/xml

9. ETag: It is the flag value of an object (such as URL). As far as an object is concerned, such as an html file, if it is modified, its Etag will not be modified. Therefore, the function of ETag is the same as that of Last-Modified. Almost, it is mainly used by the WEB server to determine whether an object has changed. For example, when requesting an html file last time, the ETag was obtained. When the file is requested again this time, the browser will send the previously obtained ETag value to the WEB server, and then the WEB server will add this ETag to the file. Compare the current ETag and then know whether the file has changed. 10. Expired: The WEB server indicates when the entity will expire. Expired objects can only be used to respond to customer requests after verifying their validity with the WEB server. Is the header of HTTP/1.0. For example: Expires: Sat, 23 May 2009 10:02:12 GMT

11. Host: The client specifies the domain name/IP address and port number of the WEB server it wants to access. For example: Host: rss.sina.com.cn

12. If-Match: If the ETag of the object has not changed, it actually means that the object has not changed, and the requested action will be performed. If-None-Match: If the ETag of the object changes, it actually means that the object has also changed, and then the requested action is performed.

13. If-Modified-Since: If the requested object has been modified after the time specified in the header, the requested action (such as returning the object) will be performed. Otherwise, code 304 will be returned to tell the browser that the object has not been modified. For example: If-Modified-Since: Thu, 10 Apr 2008 09:14:42 GMT If-Unmodified-Since: If the requested object has not been modified after the time specified in the header, the requested action (such as returning the object) will be performed.

14. If-Range: The browser tells the WEB server that if the object I requested has not changed, give me the missing part, and if the object has changed, give me the entire object. The browser sends the ETag of the requested object or the last modification time it knows to the WEB server to let it determine whether the object has changed. Always used with Range header.

15. Last-Modified: The WEB server considers the last modification time of the object, such as the last modification time of the file, the last generation time of the dynamic page, etc. For example: Last-Modified: Tue, 06 May 2008 02:42:43 GMT

16. Location: The WEB server tells the browser that the object it is trying to access has been moved to another location, so go to the location specified by the header to retrieve it.

17. Pramga: Mainly use Pramga: no-cache, which is equivalent to Cache-Control: no-cache. For example: Pragma: no-cache

18. Proxy-Authenticate: The proxy server responds to the browser, asking it to provide proxy authentication information. Proxy-Authorization: The browser responds to the proxy server's authentication request and provides its own identity information.

19. Range: The browser (such as Flashget during multi-threaded download) tells the WEB server which part of the object it wants to retrieve. For example: Range: bytes=1173546-

20. Referer: The browser indicates to the WEB server which web page/URL it obtained/clicked on the URL/URL in the current request. For example: Referer: http://www.sina.com/

21. Server: The WEB server indicates what software it is and its version. For example: Server: Apache/2.0.61 (Unix)

22. User-Agent: The browser indicates its identity (which browser it is). For example: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14

23. Transfer-Encoding: The WEB server indicates how it encodes the response message body (not the objects in the message body), such as whether it is chunked. For example: Transfer-Encoding: chunked

24. Vary: The WEB server uses the content of this header to tell the Cache server under what conditions the object returned by this response can be used to respond to subsequent requests. If the source WEB server receives the first request message, the header of its response message is: Content-Encoding: gzip; Vary: Content-Encoding Then the Cache server will analyze the header of the subsequent request message and check whether its Accept-Encoding is consistent with the Vary header value of the previous response, that is, whether the same content encoding method is used, so This can prevent the Cache server from using the compressed entities in its own Cache to respond to browsers that do not have the ability to decompress. For example: Vary: Accept-Encoding

25. Via: Lists which proxy servers the response from the client to OCS or vice versa passes through, and what protocol (and version) they use to send the request. When the client request reaches the first proxy server, the server will add the Via header to the request it sends and fill in its own relevant information. When the next proxy server receives the request from the first proxy server, it will Copy the Via header of the previous proxy server's request in the request you send, and add your own relevant information to the end, and so on. When OCS receives the request from the last proxy server, it checks the Via header. Know the route the request took. For example: Via: 1.0 236-81.D07071953.sina.com.cn:80 (squid/2.6.STABLE13). After learning the theoretical knowledge, you can refer to some articles introduced by the Script School on determining the file type based on the file header, combining theory with practice.

Articles you may be interested in: php header() function example php header function implements file download Usage of header function in php php file download class (application example of header information) Detailed explanation of php header usage php header function directly prompts for the saved code when downloading the file php header information example Detailed explanation of HEADER header message in PHP Key points of php header function



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn