Press "Enter" to skip to content

Tag: varnish

Varnish: Unable to start: SHMFILE owned by running…

If, when trying to start the Varnish reverse proxy server, you receive an error message such as: [ ]#/usr/sbin/varnishd -d -f /etc/varnish/default.vcl GeoIP plugin loaded successfully. storage_file: filename: ./varnish.8QhQpI size 4208 MB. SHMFILE owned by running varnishd master (pid=2451) (Use unique -n arguments if you want multiple instances.) but “ps auxwww | grep 2451” doesn’t show Varnish (in my case, it was dkim-milter on that pid) and “ps auxwww | grep varnish” shows nothing, then you need to manually reset Varnish’s SHMFILE settings. This is easier done than said! Just go into /var/lib/varnish/[hostname] and delete all the files in there (such as varnish.8QhQPI and _.vsl). Restarting varnish should then be successful.

Varnish: Normalizing / Normalising the url

We’ve had a small issue with our installation of the Varnish Proxy Cache not working as efficiently as we hoped. This was tracked down to the fact we are using Google Adwords and Google Analytics for tracking and Google was adding query string items such as utm_source , utm_medium , utm_campaign and gclid to the URL. This caused Varnish not to cache the page (and/or treat them as separate urls) and just led to bad cache usage. I’ve added this code to fix this which may be of use for others: /* Normalize the url – first remove any hashtags (shouldn’t make it to the server anyway, but just in case) */ if (req.url ~ “\#”) { set req.url=regsub(req.url,”\#.*$”,””); } /* Normalize the url – remove Google tracking urls */ if (req.url ~ “\?”) { set req.url=regsuball(req.url,”&(utm_source|utm_medium|utm_campaign|gclid)=([A-z0-9_\-]+)”,””); set req.url=regsuball(req.url,”\?(utm_source|utm_medium|utm_campaign|gclid)=([A-z0-9_\-]+)”,”?”); set req.url=regsub(req.url,”\?&”,”?”); set req.url=regsub(req.url,”\?$”,””); }