Viewing the webpage header is a key part of optimizing the web application. From the header, you can check a lot of information: the cache time (age) and Client Cache Time (expires) of the webpage in squid) last-modified, x-cache, server version, server time (Date), and gzip
Viewing the webpage header is a key part of optimizing the web application. From the header, you can check a lot of information: the webpage is in squIdCache Time (age), Client Cache Time (ExPires), whether there is a last modification time (last-modifiEd), Whether to hit (x-cache) in squid, server version, server time (Date), gZipCompressionContent-ENcOding. All of the above are basic information. This article describes how to use headers to analyze the client request trend.
First, we will introduce several methods to view headers:
1. httpwatch
This software is the most convenient tool in windows + ie. You can find it online and find the cracked key. You cannot view the header if no cracked version is available. After the installation is complete, there will be an httpwatch button on the ie Toolbar, and a window will be opened at the lower part of ie, with the Open button in the upper left corner of the window, after you press it, all the request links sent on the webpage are recorded in the window when you enter the address in the browser. Click any link and select header below, you can see the request header and response header for this link. One of the inconveniences of using httpwatch is that it records all the links on the web page. If there are so many links that it is difficult to find the link you want to view, so we can use its filter function to filter out irrelevant links, but when viewing the next page, we should change the filter.
2. curl
In linux, you can use curl to view the header of a link more directly. In addition, you can modify the request header to debug the target address, which is very convenient:
Curl-I http: // www.SuDone.com
In this way, we can see the response header, but this header is not compressed, so it is not obtained by most people. To view the compressed version, run:
Curl-I -- compresSedHttp://www.sudone.com
This uses the curl default request compression function, but this function still cannot obtain the compressed version in some cases ......, Execute the most primitive:
Curl-I-H Accept-Encoding:Gzip, Deflate http://www.sudone.com
This method is effective for all servers that support gzip or defalte compression. If there is still no compression (NO Content-Encoding: gzip is returned ), that is, the server does not support compression.
Record a curl to check the link of the specified ip address.ClusterThe following checks are very useful:
Curl-I-H Host: www.sudone.com-H Accept-Encoding: gzip, deflate http: // 64.233.189.99/
Use with a wget:
Wget-S -- spider http://www.sudone.com
Wget does not use the header function very well, so it is not commonly used.
3. firebug
If you use linux as the desktop and want to debug a webpage with cookies or sessions, it is inconvenient to use curl. In this case, you can only debug it through a browser, in linux, there is a widely supported browser firefox (iceweasel). After installing the firebug plug-in firefox, you can easily view the response header. You can check the use of firebug on the Internet. It should be said that it is more convenient, and other functions of firebug are also relatively strong.
With the above methods, it is not a big problem to view the header.
The following describes how to use the header to analyze the client request direction:
Because lvs or other typesServer Load balancerTherefore, it is inconvenient to check for some trivial faults. For example, if a machine is inconsistent with the program version on other servers due to various reasons, it is difficult to query. By printing the header, you can easily find the problematic machine. The print header prints a string representing the local machine to the response header. Generally, the via header can be passed through squid, after passing through, the display sequence is still from the largest machine to the outermost machine, and the entire flow is clear at a glance.
You can print the header using a program (jsp/Php) Print, you can also use the server to print, introduce several kinds:
1. squid
Modify visible_hostname 64.233.189.99.cache.sudone.com In the squid configuration file to mark the machine so that the machine name can be seen in the response via header. The common method is to mount the IP address.DdOS. You can add some codes.
2. nginx
In the configuration, click add_header via $ server_addr to print the local IP address to the via header. In addition, if nginx is used as the Server Load balancer frontend, It is very convenient to print the backend address, input: add_header via $ upsTrEam_addr.
3. apache
Apache can modify the header Through the header module. If you are not familiar with it, check it.
4. Dynamic programs
Dynamic programs are quite flexible, but too many types cannot be described one by one.