Personalizing cached HTML pages with Varnish

Varnish logoEveryone is using Varnish to speed up their sites nowadays. Varnish greatly decreases page load time on websites with mostly anonymous traffic. But many anonymous sites still need to personalize content a bit based on user geo location, time-of-day, the languages the browser claims to support, etc.

One approach would be to store different versions of the site’s HTML in cache thus reducing hit rates and increasing page load time as a result. A better approach is to set the user’s cookie using the Varnish vcl_deliver method and then manipulate the UI with JavaScript based on this cookie.

Varnish comes with a variety of modules that allow you to learn a user’s country, normalize request header values, etc. You can then use this data to calculate the user’s cookie value!

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting this form, you accept the Mollom privacy policy.