If you are using Drupal on a virtual or dedicated server and you haven't yet installed Varnish then make sure you set aside some time in the near future to do so. It is, by far, the most effective way of presenting a cache to anonymous users.
The best guide for setting up Varnish can be found in the excellent Lullabot video Drupal Performance & Scalability. This video covers Varnish, Pressflow and PHP and MySQL optimisation techniques. However, although only released at the turn of the year, some of the information is now out of date. For instance, it recommends using a replacement init script for memcached; but the latest version of the Memcache Drupal module makes this script redundant.
You can also find help on the Drupal Performance group site.
One big issue with Varnish is that the presence of even a single cookie will mean the user bypasses the cached content. That is why it is essential to use Pressflow because it removes unnecessary session cookies that can be found in Drupal.
If you follow the existing guides carefully then you shouldn't encounter too many problems installing Varnish, however trying to deal with Google Analytics cookies gave me a real headache.
There is a Drupal-optimised Varnish configuration file script that is possible to cut and paste into the default.vcl file; but getting to grips with it requires knowledge of the homegrown language that it uses, details of which can be found here.
In the script linked to above there is a line that strips Google Analytics cookies before it is processed, thus allowing the cache to proceed.
// Remove has_js and Google Analytics cookies. set req.http.Cookie = regsuball(req.http.Cookie, "(^|;s*)(__[a-z]+|__utma_a2a|has_js)=[^;]*", "");
I've tried the above code and a number of different variations that I found elsewhere on the web and I couldn't get the cache to work with Google Analytics. There is clearly something fundamental I'm misunderstanding about how the script processes cookies.
However, there is an alternative to the standard JavaScript analytics code and which is not dependent on cookies.
Because a number of mobile phone browsers don't accept JavaScript or cookies, in 2009 Google released a version that was non-JavaScript and non-cookie analytics code for sites aimed at this market.
So what is good for mobile phones is good for Varnish. When you sign up and grab the code click on the advanced tab and then click on “a site built for a mobile phone” and from there use the code provided.
As an aside, I use a couple of co.cc domains for sites in development. I couldn't get Google to recognise the tracking code when placed on co.cc domains. Has anybody else encountered this problem before? It is mickey mouse domain so I suppose there must be problems with the DNS.