Testing Varnish

Spotting a cached page

Varnish sets headers to give some clues.

Open Chrome Developer tools by hitting F12 navigate to the network tag and click on the page, filtering by Doc should make this easier to find.

The two headers are X-Varnish, which tells you if varnish is hit, and X-Cache which will give more details on if there has been a cache HIT or MISS.

Warning

Varnish can be setup to exclude these headers, if they are not on the page it does not mean varnish isn't in use.

Looking out for Cache leaks

A cache leak is where information which is meant to be dynamic for a page is cached and delivered where it should not be.

To test this you can often just hit a page multiple times under different circumstances, some common cache leaks on a magento store are:

User Account Info

Log into the user account area as one user and then hit it again as another with out clearing the cache. Each user should have the correct details, if the second user see the details of the first the means user information is being cached.

User Info on other Pages

Often over looked is account info on pages outside of the account page.

You can test this the same way by logging in as different users and looking out for any where your site has a personalised message i.e. 'Thanks for ordering [User]'

Blocks on template pages

Magento makes use of the same templates to generate multiple pages, some times these can include a block loaded by the template which needs to be different i.e. a category description.

This is more likely to happen with custom blocks, if you have extra functionality on category or product pages it is good to check.

The only real way to test this is to navigate the site once the cache is warm and pay attention to the content of each different part of the site, is the product description describing the correct product? are the related product relevant to this? etc.

Turpentine Varnish module for Magento

The docs can be found here. I have used snippets from these below.

Concepts

ESI_Cache_Policy

A Magento page is made up of blocks, the ESI_Cache_Policy define how each block should be stored.

Block Access

This is what user a block is cached for.

1
2
3
private        : one version per client is stored in cache (the session cookie identifies which client gets which cached version of the block)
public         : one version of a block is stored for the entire website (only one cached version of the block exist and it is served to every client)
customer_group : one version per customer group is stored in cache (special customer group cookie is used)
Scope

Some times you have blocks used on multiple pages, maybe the links in the footer. This is defined by the scope.

1
2
page   : one version of the block is cached per page (identified by the URL)
global : one version of the block is stored for the entire site