TWEAK: Peer Squid Caching Proxy Server

Following up with the install and configuration with another squid proxy tweak.. Setting up your own squid caching proxy server on your very own Windows machine at home is very beneficial, but there are more of those that remain unstated. If you happen to have multiple caching proxy servers set-up, you can further tweak them to share their caches. They help each other, so to speak.

That is another benefit of having a caching proxy server. Regardless of whether there are hardware limitations on memory and hard drive space, proxies can be set-up as peers. And this is not limited to just two (2) peers. You can have many peers set-up to help each other out with the caching. Fetching from local cache is faster than fetching the same information from the web, which definitely helps speed-up browsing.

It doesn't take rocket science to set this up. The same procedure in setting up a squid caching proxy server is followed. The configuration file is the pretty much the same, only tweak it a little to let squid know the peer exists. This part of the previous squid.conf is very important.

icp_port 3130
icp_query_timeout 5000

It is required for peer caches to be able to query each other. The directive icp_port 3130 tells squid to listen to port 3130 for peer queries. And icp_query_timeout of 5000 means the timeout of a peer query is 5 seconds, ample enough to wait for timeout between proxies. That is what I have in my configuration, test it out to see which applies best in your environment.

The other directive that is required for a peer cache proxy is cache_peer. It lets squid know who the peers are and which port it listens to. Further information about this directive and its options are on the squid documentation. The code to use is below:

cache_peer [peer_proxy_name or ip_address] http_port icp_port options 

Note that in the above syntax, http_port and icp_port both refer to the ports used on the peer, not on the local proxy server. It helps to simplify things by using the same ports for peer caches.

In order to see if the peer caches really query each other, you may wish to turn on access_logging. Checking the squid.conf.default file you can see that the original directive for this is:

access_log c:/squid/var/logs/access.log squid

Just replace the line "access_log none" with the above code. Then, re-configure squid to reflect the changes.

After browsing for a bit, check the log file and see if the IP address (or hostname) of the peer cache proxy appears on the log. That should be a good indication that the proxies are now helping each other out.

On this part, it is easy to miss the portion where you configure the browser. I have had many experiences of trying to troubleshoot the proxy (and wasting precious time in the process) only to find out the browser was never configured to use the proxy in the first place. Lessons learned here, so the first question I always ask is: Have you configured the browser to use the proxy?

You might also be interested in:


We at pimp-my-rig strive to keep on improving, help us reach that goal by leaving comments or constructive criticisms. Don't miss out on our next feature -- subscribe via RSS (What is RSS?).

Share This