I have had a squid proxy running on my NAS for ages, but I was never really able to quantify the effectiveness of the cache. There are a lot of small scripts that parse the squid logs and output some statics, but that is not very satisfactory. Today I realised that Squid offers some kind of web UI to visualise the state of the cache manager.
The squid cache manager is basically two parts, one part that runs on the squid proxy itself, and cgi-bin
program that can be run on any web-server. As I did not see the point in starting a web server on my NAS just for that, I decided to run the cgi
program on my laptop. Here are the steps to get this running. This assumes you know how to use vi and have ports installed on your Mac.
- Connect to your NAS as root
vi /opt/etc/squid/squid.conf
- Find the line with this text
http_access allow manager localhost
and addhttp_access allow manager localnet
just below. This will grant access to the cache-manager to your whole LAN. - Restart Squid:
/opt/etc/init.d/S80squid restart
. - Logout of your NAS.
- On your mac, install Squid
sudo port install squid @2.7
- Go to your CGI bin directory
pushd /Library/WebServer/CGI-Executables
- Install the cgi client
sudo ln /opt/local/libexec/squid/cachemgr.cgi ./
- Edit the configuration file of said tool
sudo vi /opt/local/etc/squid/cachemgr.conf
- Replace
localhost
with the hostname/address of your NAS. - Point a web browser to the address
http://127.0.0.1/cgi-bin/cachemgr.cgi
. - The web-UI will ask for some name/password pair, give any random thing
- You should see a web UI to Squid.
And did find any effectiveness?
In a personal environment, I don’t see the point for a proxy, except in one case: filtering proxy with parental control for children.
With the default settings, the cache hit rate is 13%, nothing exceptional, but still a win, in particular for my phone at home. I think I could improve this by overriding the TTL of the static content provider and tracker sites.