What is Xache
Xache, pronounced as Zash, is the missing piece in the Drupal-Varnish puzzle.

The problem
You think your website is slow? Just add Varnish at the back and things will improve drastically. But, the pain with Varnish is - it's dumb. It just caches all the pages till they time out. So, say, if you update the content of an article. Users won't be able to see the updated article for the next 24 hours, or 48 hours or whatever the time out you have set in your Varnish configuration. Sure, you can set the time out to a very low value of say 1 hour but then, it would defeat the purpose of using Varnish in the first place as you wouldn't see that much of a performance gain.

The solution
The solution is to add a magic value to the HTTP header of each page through which Varnish can identify what content types are being displayed on that page. Then, when a node is added/updated, let Varnish know. This module does just that.

Installation

  1. Download.
  2. Enable.
  3. For Varnish, copy this to your default.vcl at the end of sub vcl_fetch.
    if (beresp.status >= 200 && beresp.status < 400 &&
        (req.request == "PUT" ||
         req.request == "POST" ||
         req.request == "DELETE")
       ){
        ban("obj.http.Xache-Contains ~ " + beresp.http.Xache-Remove);
    }
  4. Clear cache for all pages just one time. If you have a module for that, you already know how to do it. If you are a command line enthusiast, do this varnishadm -T :6082 "ban.url /", where 6082 is the default Varnish port number.
  5. Done and done. Now, cache for pages will be removed if and when they are updated. Automatically. That's the beauty of Xache - plug-it and forget-it.

Other than Varnish
It can work with other caching servers too. You may follow the instructions in the step 3 above to rewrite the code for your own caching server. Please share with me if you do, so it can be of help to others too.

Future of Xache
We want to make Xache more intelligent so it can clear the cache in other scenarios too - when a block's title is updated, when a new block is added, etc. We are working on it right now, and making sure it doesn't affect the performance along the way. Keep a look out for updates.

Similar modules
You can achieve the same functionality with a combination of Cache Expiration and Purge as well. You can define for what pages the cache should be cleared by adding various rules. So, it goes like - when this content type is updated, clear the cache for this, this and that page. It's very cumbersome to setup, you have to define a lot of rules if you have a lot of content types going on. Also, what if admin just adds a new page, who will add a rule for that? Xache is the simple yet elegant solution to all this.

Project information

  • Module categories: Performance
  • Created by rmn on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    Look for the shield icon below.

Releases