varnish on NetBSD, 2010-12-01 16:40:06 #
So for a while now i have been admiring varnish for its crazy speed. So I decided to add it to my system and try out a few things.
-
pkgsrc
- First I went to pkgsrc only to find varnish 2.0. I wanted the latest, varnish 2.1, so I had to upgrade that. There are also rc scripts included in there, but they're very rudimentary.
- Next I needed to get varnish actually functioning, which required a few changes to my apache config (moving it to a different port).
Listen 0.0.0.0:8282 ... NameVirtualHost *:8282 <VirtualHost *:8282>
- Then actually setting up varnish
#/etc/rc.conf varnishd=YES varnishd_flags="-a 0.0.0.0:80 -f /usr/pkg/etc/varnish/default.vcl -s malloc,25m"
#/usr/pkg/etc/varnish/default.vcl backend default { .host = "127.0.0.1"; .port = "8282"; } -
Now getting things to actually cache. Using google analytics means cookies are always set for everything.
#/usr/pkg/etc/varnish/default.vcl sub vcl_recv { if ( req.url ~ "^/static/" || req.url ~ ".+\.html$" || req.url ~ ".+\.js$" || req.url ~ ".+\.css$" || req.url ~ ".+\.jpg$" || req.url ~ ".+\.gif$" ) { unset req.http.Cookie; } }
And that's pretty much it. I can keep messing around to get my hit rate up and I would like to setup different backends based on my Host headers, but otherwise I'm happy. 25MB is also really small.