Debugging Squid and CacheFu locally on Mac OS X
From the Real-Developers-Do-It-Locally-Department
When using Squid and CacheFu it can be quite handy to have a duplicate (or at least similar) setup on your local development machine in order to debug header settings etc. If your development platform is Mac OS X, as is mine, you might find the following how-to useful.
After some trial and error I came up with an approach that puts all the customization into the CacheFu part of the equation and thus allows for the luxury of a simple ./configure ; make install installation of Squid. (The reason we need to install Squid from source is that CacheFu explicitely requires version 2.5 and i.e. Darwin ports already has upgraded its squid package to version 2.6.) Having said this, here are the necessary steps:
- Download and expand the Squid 2.5 sources which can be found here
- Inside the expanded package, simply issue the standard
./configure ; make ; sudo make install Next, we need to adapt CacheFu’s
squid.cfgfile to match Mac OS X’s environment and what the previous step produced:[python]
binary: /usr/bin/python2.3
[squid]
binary: /usr/local/squid/sbin/squid
user: nobody
config_dir: /usr/local/squid/etc
log_dir: /usr/local/squid/var/logs
cache_dir: /usr/local/squid/var/cache
cache_size_mb: 1000
direct: True
port: 3128
admin_email: somebody@somewhere.org
[supported-protocols]
http: 80
https: 443
[accelerated-hosts]
HOSTNAME.local: localhost:ZOPEPORT/SITENAME/The only changes you will need to make are the accelerated-hosts entries, where you obviously will want to replace
HOSTNAME,ZOPEPORTandSITENAMEwith values appropriate to your setup.- Now we can let CacheFu do its magic and generate the actual squid configuration for us (kudos to Geoff for writing this script!):
python makeconfig --config=squid.cfg --templates=templates/ --output=output/ Before deploying we need to adjust ownerships and create a missing directory:
sudo mkdir /usr/local/squid/var/cache
sudo chown -R nobody /usr/local/squid/varNow we can deploy the generated setup:
cd output ; sudo python deploy- … let squid create its necessary files and directories:
/usr/local/squid/sbin/squid -z - … and finally start up squid
sudo /usr/local/squid/sbin/squid(thesudois necessary to enable the squid process to bind to port 80)
Now you can access your plone instance via http://HOSTNAME.local and debug the Cache-Headers it sends.
