Network Topology

Cached Page Control

Varnish and Joomla don't naturally play nice.  Varnish wants to cache everything, and requires a list of pages to NOT cache, and there isn't really a mechanism within Joomla to indicate which pages should be cached and which not. It occurred to me that I wrote a plugin to do that exact thing - but with browser cache.  So why not adapt that for use in Varnish?  I mean, Varnish can inspect headers...

Varnish and Joomla controlled by System - Expires Headers

My plugin is pretty simple to use.  You can define any number of cache configurations and assign those to menu items.  More specifically, you can define which pages NOT to cache with a few simple settings and menu item selections. To be extremely specific, these are the settings to use in order to trigger my version of Varnish config to NOT cache a page:

  • Expires: Off
  • Cache-Control: On
  • Cacheable: no-cache
  • Check all 3: no-store, must-revalidate, and Pragma: no-cache

Then just apply it to as many of your menu items as need to be NOT cached. One thing to remember, if the page is ONLY visible to logged in users, it will never be cached - so no need to choose those menu items.

Varnish and Joomla has never been easier.

Joomla Cache

This setup eliminates the need to use Joomla's Page Cache plugin.  The ability to set global expires headers using the Expires Headers plugin, and Varnish level caching removes the caching burden from Joomla.  One less plugin means less activity and faster dynamic page loads.  This doesn't do anything to other cached content types (module cache, plugin cache, etc).

Final Thoughts

Is this the absolute best configuration for Varnish and Joomla?  Absolutely not.  This is as much a starting point for me as it is for you.  Maybe I have a little bit of a head start, but certainly there is someone smarter out there willing to devote some time to making this better.  I sincerely hope they're willing to share their work as I have done here.

I am open to both suggestions and criticisms.  By all means, tell me what I did wrong (or right, if you feel generous).  I'm certain that there are improvements to be made and I'm not too proud to ask for them.

Good luck, and may your sites be super fast.