Skip to content. | Skip to navigation

Sections
Personal tools
What is this?
Hi, my name is Tom Lazar and I'm a Plone and Zope developer based in Berlin, Germany and this is my personal and professional (no big difference, really...) website.
 

Debugging Squid and CacheFu locally on Mac OS X

Filed Under:

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:

  1. Download and expand the Squid 2.5 sources which can be found here
  2. Inside the expanded package, simply issue the standard ./configure ; make ; sudo make install
  3. Next, we need to adapt CacheFu’s squid.cfg file 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, ZOPEPORT and SITENAME with values appropriate to your setup.

  4. 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/
  5. 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/var
  6. Now we can deploy the generated setup: cd output ; sudo python deploy

  7. … let squid create its necessary files and directories: /usr/local/squid/sbin/squid -z
  8. … and finally start up squid sudo /usr/local/squid/sbin/squid (the sudo is 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.