PHPHTTP protocol (Header/status code/cache)

Source: Internet
Author: User
I. Introduction to HTTP Protocol 1. # HTTP protocol # (1) built on the TCPIP protocol # (2web Development Data Transmission relies on http # (3http stands for text transmission protocol 2. HTTP message Header GETtesttest. phpHTTP1.1 indicates the resource Accept of the get request sent: ** Referer: localhost: 80

I. Introduction to HTTP Protocol 1. # HTTP protocol #(1 is based on the TCP/IP protocol #(2. web Development Data Transmission relies on http protocol #(3. Full name of http protocol is text transmission. protocol 2. HTTP packet header GET/test. php HTTP/1.1 // indicates the resource Accept of the get request sent: */* Referer: http: // localhost: 80

1. Introduction to HTTP

1. # HTTP protocol
#(1 based on TCP/IP protocol
#(2. web development data transmission depends on the http protocol
#(3. The full name of http protocol is text transfer protocol.

2. HTTP packet header

GET/test. php HTTP/1.1
// Indicates the get request resource sent
Accept :*/*
Referer: http: // localhost: 8082/test. php
Accetp-Language: zh-cn // page Language
User-Agent: Mozilla/4.0 // browser kernel and Operating System
Accept-Encoding: gzip, deflate // data compression format
Host: localhost: 80 // Host, default 80
Connection: Keep-Alive // Keep the Connection and do not disconnect the request immediately

// Obtain information
Print_r ($ _ SERVER); // view all information
Foreach ($ _ SERVER as $ key => $ val)
{
Echo $ key. "->". $ val ."
";

}
Echo "your IP address is:". $ _ SERVER ['remote _ ADDR '];

If ($ _ SERVER = "ip address ")
{Header ("location: err. php ");}

3. Difference Between get and post

(1) Security: The data of the get request is displayed in the address bar, and the data of the post request is placed in the http message body. The post is highly secure.

(2) Size of submitted data: (http itself is not limited in size, but it is limited by the browser) if the get request data is 2 K + 35 = 2083 post, there is no limit

(3. get is more conducive to favorites. get will include URL parameters, but post will not

4. HTTP status code

HTTP/1.1 200OK [200 OK indicates that the client is successfully requested]

Server: Microsoft-IIS/5.0 [tell the browser about the Server]

Date: Thu, 12,2013 12:58:21 GMT [current time of the requested page]

Last-Modified:... [cache latest update time]

Content-Length: 2291 [number of returned bytes]

Content-Type: text/htm [document Type]

Cache-control: private [Cache]

    

302: Jump to other pages

304: cache; No Modified has not been Modified

5. Response interval through HTTP

// Header ("Refresh: 5; url = www.cnblogs.com/daomul ");

Header ("Refresh: 5; url = htt [: // locahost: 8082/test. php ");

?>

6. Disable cache settings

Header ("Ecpires:-1 ");

Header ("Cache-control: no-cache ");

Header ("Pragma: no-cache ");

// The latest version is obtained each time. The above three items are used at the same time to ensure browser compatibility.

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.