Use Dnspod and squid to build your own CDN (eight) test and run Squid_linux

Source: Internet
Author: User
Tags curl current time ranges
The 8th chapter tests and runs Squid

1. Preliminary preparation

Want to test squid is normal, must first www.naizhao.com this domain resolution to 2.2.2.2 this IP. As with the previous chapter, if you are a netcom users do not need to do anything, Dnspod will give you back to 2.2.2.2 this IP. If you are a telecommunications user, or the resolution of the IP is not 2.2.2.2, then it is necessary to modify the system hosts table, corresponding records added. Unlike the previous chapter, the previous chapter modifies the hosts table for squid servers, and you now need to modify the hosts table for the system you use to test squid.

In addition to modifying the hosts table, we also need a gadget called curl. The general Linux/unix system comes with this tool, and if you use Windows, you need to download one to the following address and put it in D: (or somewhere else, like it yourself).

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

HTTP://CURL.HAXX.SE/LATEST.CGI?CURL=WIN64-NOSSL (64-bit system)

Download back after decompression, we only need a curl.exe.

2. Running Squid

We continue to use the previous chapter of the method, with the debugging method to start Squid

Cd/usr/local/squid/sbin

./squid-nd 1

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

If you can display a normal page, then squid has been running normally. But we also need to make sure that the desired page has been cached by squid.

3. Test Squid

We use curl, enter the following command (Windows user please use command line to run Curl)

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

http/1.0 OK

Date:sun, April 2007 12:16:27 GMT

Server:naizhao Web server/1.0.0

last-modified:wed, Dec 2006 06:11:14 GMT

ETag: "7665b-1983-4417e480"

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, and the following line indicates that there is no hit cache. That is, you do not read the required files from the cache. Generally, the first time you access a file, the appearance of Miss is normal, because the original file does not exist in the cache.

X-cache:miss from cnc.naizhao.com

Then we rerun the command and continue to see what the output

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

http/1.0 OK

Date:sun, April 2007 12:16:27 GMT

Server:naizhao Web server/1.0.0

last-modified:wed, Dec 2006 06:11:14 GMT

ETag: "7665b-1983-4417e480"

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

As you can see, this output is already hit. This means that the content is read from the cache.

If the second visit is still miss, then you need to check to see if the page restricts caching. Here are some things to start with:

last-modified:wed, Dec 2006 06:11:14 GMT checks whether this line changes each visit. If it keeps changing, the description page is dynamic and does not fit the squid cache. Squid checks the line at every request to determine whether the page has expired and to retrieve the expired page.

Cache-control:no-store, No-cache, Must-revalidate, post-check=0, pre-check=0 this line is responsible for controlling caching. No-store, No-cache, must-revalidate, etc. are required squid to prohibit caching of content, and each request to verify that the page is expired.

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

Pragma:no-cache This sentence is also prohibit caching.

We can follow the contents of the above self-examination self correction, according to the actual needs of the site to modify it.

After confirming that there are no problems, we can get the squid to run properly.

4. Official Running Squid

ULIMIT-HS 65536

Ulimit-n 65536

./squid

Use the above command directly to get squid running.

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

5. Let squid follow the system to start

CentOS let squid follow the system to start very simple, only need to edit/etc/rc.local, at the end add the following content can

ULIMIT-HS 65536

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.