Varnish Cache: How does Varnish play with other caching systems?

i-CONICA asked:

I’m considering installing Varnish cache in front of my forum platform to speed it up even further.

It already runs Percona MySQL DB, PHP 5.5.8 (which has Opcode caching built in, and running) and memcached. The site runs through a CDN, which also caches some resources.

EDIT: There’s no clustering, it’s a single server.

Is Varnish a duplication/conflict of any of my current caching layers, or will it be a good addition to my existing caches?


My answer:

Varnish only has a chance to help if most of the visitors to your site are anonymous, i.e. they never log in and participate. Requests by logged-in users cannot be safely cached at this level, and any reasonable web site will set Cache-Control: private (or perhaps no-cache if it’s less well designed) to indicate this.

However, your forum software itself may work against you. For instance, SMF sets Cache-Control: private and cookies even for anonymous users; the former breaks caching and requires extreme gymnastics to work around. This is utterly broken behavior, but I don’t expect it to change soon.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.