I’ve been using the free Squid proxy on my Mac and Windows notebooks for a few weeks.
One motivation was the horrible wifi access during my last trip to Asia, especially the HK airport departure area. Both DNS lookups and HTTP requests were glacial, with name lookups taking 1 second or more – as if the sites were hosted on the moon.
The main feature of Squid is that it transparently caches (makes a timestamped copy) of files that are downloaded from a network connection, so you only need to fetch them once.
Squid also has additional security features, like ACLs, and load balancing.
The advantages of running Squid on my notebooks are:
- even though web browsers have a cache manager, squid still reduces page load times, the result being pages load 2x to 5x faster with squid proxy. Generally I use 8 Mbps DSL and local public wifi hotspots for Internet access. In areas with unreliable Internet access, the benefits of Squid would be even more dramatic.
- web site pages are more likely to finish loading within a reasonable timeframe (browser status bar says “Done” in a few seconds)
- the WordPress admin UI is actually usable for the first time in recent memory, indicating that AJAX apps are also helped by caching JavaScript.
The minor disadvantages include:
- it is possible that a stale object could be cached. If you’re a web designer or digital artist, you should be aware of that and know how to clear the cache. To force cache clearing of a specific item you can use the squidclient command line tool:
squidclient -m PURGE 'URL'
- anybody who gains access to your notebook would be able to see what sites you’ve visited, so it would be a good idea to clear the cache weekly.
Installation
Mac OS X
Squid is trivial to install on a Mac with MacPorts installed:
sudo port install squid
sudo port load squid
# configure your browser's proxy setting to point to http://127.0.0.1:3128
To uninstall Squid later:
sudo port unload squid
sudo port uninstall squid
To clear the Squid cache:
sudo port unload squid
sleep 10
sudo squid -z
sudo port load squid
Microsoft Windows
The Squid Windows port is available from 2 places:
- Running a Squid Proxy Under Windows No configuration is needed for use on localhost.
- Acme Consulting.
Resource consumption by squid with the default configuration is negligible with any computer made in the past 5 years.
Squid Reporting
Squid comes with a basic textual reporting tool called cachemgr.cgi. Sadly, it requires that you install apache or IIS to run it – the program should have been written as a built-in squid resource.
CacheMgr does give you basic reporting on cache hit rates and object usage, but end-users will get bored in a day or so, at which time the web server can be uninstalled.
Some issues to consider when using CacheMgr, which can largely be mitigated with binding the web server to localhost or using a .htaccess file:
- access to the remote shutdown facility
- access to who is downloading what could be fairly sensitive information (Cache information shows FDs with the IP and the URL they are accessing)
- maybe a resource drain while listing Objects
- running a web server is required.
webalizer is a cross-platform graphical web reporting tool that can parse squid logs and is easy to install. It can be run from the command line and generates HTML and graphics files that can be viewed locally or shared using a webserver.
Squid LAN Configuration
To allow multiple computers to use a single squid proxy, squid.conf would need to say something like:
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
acl mylan src 192.168.10.0/255.255.255.0
http_access allow mylan
http_access deny all
cache_dir /squid.cache 5000 16 256
Squid FAQs