Use DNSPod and Squid to build your own CDN (8) test and run SQUID

Source: Internet
Author: User

Chapter 4 test and run SQUID

1. Preparations

To test whether SQUID is normal, you must first resolve the domain name www.naizhao.com to the IP address 2.2.2.2. As in the previous chapter, if you are a Netcom user and do not need to perform any operations, DNSPod will return the IP address 2.2.2.2 to you. If you are a telecom user or the resolved IP address is not 2.2.2.2, you must modify the hosts table of the system and add the corresponding records. Unlike the previous chapter, the previous chapter modifies the hosts table of the SQUID server. What you need to modify now is the hosts table of the system you use to test SQUID.

In addition to modifying the hosts table, we also need a small tool named curl. This tool is usually included in Linux/Unix systems. If you are using Windows, you need to download one from the following address and put it to D: (or somewhere else, as you like ).

Http://curl.haxx.se/latest.cgi? Curl = win32-nossl (32-bit System)

Http://curl.haxx.se/latest.cgi? Curl = win64-nossl (64-bit System)

After the download is decompressed, we only need one curl.exe.

2. Run SQUID

We continue to use the method in the previous chapter to start SQUID through debugging.

Cd/usr/local/SQUID/sbin

./SQUID-Nd 1

Then open the browser and enter the http://www.naizhao.com to see if the output page is correct.

If a normal page is displayed, it indicates that SQUID is running properly. However, we also need to check whether the required page has been cached by SQUID.

3. Test SQUID

We use curl and enter the following command (for Windows users, run curl through the command line)

Curl-I http://www.naizhao.com/

HTTP/1.0 200 OK

Date: Sun, 08 Jul 2007 12:16:27 GMT

Server: NaiZhao Web Server/1.0.0

Last-Modified: Wed, 13 Dec 2006 06:11:14 GMT

ETag: "7665b-1983-4417e133"

Accept-Ranges: bytes

Content-Length: 6531

Vary: Accept-Encoding

Content-Type: text/css

Age: 29155

X-Cache: MISS from cnc.naizhao.com

Via: 1.0 cnc.naizhao.com: 80 (SQUID/2.6.STABLE13)

Connection: close

We pay attention to the output content. The following line of content indicates that the cache is not hit. That is, the file is not read from the cache. Generally, it is normal to MISS a file when it is accessed for the first time, because the file does not exist in the cache.

X-Cache: MISS from cnc.naizhao.com

Then, run the command again to view the output content.

Curl-I http://www.naizhao.com/

HTTP/1.0 200 OK

Date: Sun, 08 Jul 2007 12:16:27 GMT

Server: NaiZhao Web Server/1.0.0

Last-Modified: Wed, 13 Dec 2006 06:11:14 GMT

ETag: "7665b-1983-4417e133"

Accept-Ranges: bytes

Content-Length: 6531

Vary: Accept-Encoding

Content-Type: text/css

Age: 29155

X-Cache: HIT from cnc.naizhao.com

Via: 1.0 cnc.naizhao.com: 80 (SQUID/2.6.STABLE13)

Connection: close

We can see that the output is already HIT. That is, the content is read from the cache.

If the second access is still MISS, you need to check whether the webpage has limited the cache. You can start from the following aspects:

Last-Modified: Wed, 13 Dec 2006 06:11:14 GMT check whether the row is changed every time. If the changes keep changing, the page is dynamic and it is not suitable for SQUID caching. In each request, SQUID checks this line to determine whether the page has expired and obtains the expired page again.

Cache-Control: no-store, no-cache, must-revalidate, post-check = 0, pre-check = 0 this row is responsible for controlling the Cache. No-store, no-cache, must-revalidate, and so on all require SQUID to prohibit cached content, and verify whether the page has expired each request.

Expires: Thu, 19 Nov 1981 08:52:00 GMT if the expiration time is greater than the current time, it is also considered that the page has expired and needs to be retrieved again. Such a page will not be cached.

Pragma: no-cache is also prohibited from caching.

You can perform self-check and self-correction based on the above content and modify the website as needed.

After confirming that there is no problem, we can officially run SQUID.

4. Run SQUID

Ulimit-hs65536

Ulimit-n 65536

./SQUID

Run the above command to run SQUID.

After running up, enter the http://www.naizhao.com to see if the access is normal.

5. Let SQUID follow the system startup

CentOS makes it easy for SQUID to follow the system startup. You only need to edit/etc/rc. local and add the following content at the end.

Ulimit-hs65536

Ulimit-n 65536

/Usr/local/SQUID/sbin/SQUID

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.