Services

  • Drupal CMS Developer
  • Website speed optimisation
  • Drupal 6 to Drupal 8 migrations

Welcome

Welcome, I am a Web Developer based in Madrid, Spain originally from the UK. I studied Computer Science & eBusiness at Loughborough University. I specialise in Content Management System websites

Varnish

Varnish + CDN - if file doesn't exist fetch from another domain

If you are working with complicated sites with CDNs, especially with imagecache whereby because Drupal says to replace the domain with a CDN domain, the URL called is not Drupal and so never generates the image, then heres the solution. I use varnish as well so am able to say "if the image returns a 404 error, try fetching it from original Drupal domain"

  if (req.url ~ "\.(png|gif|jpg|swf|css|js)$" && req.http.host ~ "^mycdn\.domain\.com" && beresp.status == 404 ) {
      set req.http.Host = "mydrupal.domain.com";
      return(restart);
  }

Varnish multiple domains but images shared

Ever had a Drupal multisite where the images are all stored in the same folder and shared for all sites? Ever installed varnish and noticed how much RAM gets used by photos? Well I did, and realised that I had 5 copies of every image, one for every domain. Easy thing to fix this:

  if (req.http.host !~ "^maindomain\.com" && req.url ~ "my/images/folder") {
    set req.http.host = "maindomain.com";
  }

Can't set custom log format for Varnishncsa with systemd

In the old days before systemd we updated /etc/default/varnishncsa enabling it and setting a custom format should we so choose. Now its a little more complicated. As this file says:

# Note: If systemd is installed, this file is obsolete and ignored.  You will
# need to copy /lib/systemd/system/varnishncsa.service to /etc/systemd/system/
# and edit that file.

Syndicate content