A Quick Guide to MODX Caching Packages

Caching has always been a core component of MODX, but these valuable Add-on Packages help you fine-tune and implement a caching strategy specific to your site.

By YJ Tso  |  July 9, 2013  |  3 min read
A Quick Guide to MODX Caching Packages

If Cache is King...

In the world of website performance, Cache is King. Well, actually optimizing your codebase should come first, but assuming you've done that, the preeminent methods for increasing site speed all involve caching at some level. In this post we're going to explore the robust Add-on Packages in the MODX Extras Repo that can help you implement a finely-tuned, custom caching strategy.

Core Caching

Before we dive into the Add-on Packages, let's quickly review what MODX's core caching mechanism does, and how it does it:

  • By default, writes cache files to the local filesystem under the /core/cache/ folder in various partitions
  • Caches the output of any cacheable Resource in the resource cache partition, on first request
  • Clears the cache when a Resource is saved, or created - unless the "Empty Cache" option is manually disabled


URL in Extras Repo: http://modx.com/extras/package/getcache
Documentation: https://github.com/opengeek/getCache/wiki

getCache allows you to store the output of specific Snippet calls and Chunk calls from your template into a custom folder location that you specify, which can optionally persist even after the Resource cache is cleared.

Use case example: you have global elements like navigation, footers, etc that don't need to be refreshed every time a new Resource is published. These elements may include slower queries, etc that can beneifit from being cached on a more persistent basis. getCache lets you do all that and more.


URL in Extras Repo: http://modx.com/extras/package/statcache
Documentation: https://github.com/opengeek/statcache/wiki

statcache renders fully cacheable resources into flat, static files. A server directive is required to try the statcache location on the filesystem first, and only if the static file does not exist will MODX then handle the request.

Use case example: you have certain pages that don't contain any dynamic content, such as an "about" page, but receive a lot of traffic. By circumventing php entirely for those requests, your server can deliver more responses with less processor load.


URL in Extras Repo: http://modx.com/extras/package/microcache
Documentation: https://github.com/opengeek/microcache/wiki

microcache sets public cache-control headers on cacheable Resources so that browsers and upstream proxies can cache responses, reducing load on your server.

Use case example: pretty much every MODX site can benefit from this. The plugin is smart enough to know when a Resource isn't cacheable, like a session-dependent one, so you just install the plugin and watch the magic happen.


URL in Extras Repo: http://modx.com/extras/package/cacheguard2

cacheguard registers an ExtJS script to uncheck the "Empty Cache" checkbox when a Manager user edits an unpublished Resource. On the save event, it clears the cache for that one Resource only so new changes can be viewed.

Use case example: if your site gets frequent content updates, then most likely your content editors frequently save their work-in-progress. By preventing the cache from being cleared on these frequent save events, the cache for Live Resources will survive longer and help reduce server load. Can be manually overridden on every save event.

Alternate Cache Providers

Out-of-the-box, MODX also supports these alternative cache providers:

Of course you need to ensure the required PHP extensions are installed on your server. In multi-node environments you can use the Remotes plugin to synchronize the disparate local caches. These two providers cache in memory rather than on the filesystem, so as long as you've provisioned sufficient RAM, you will gain noticeable speed improvements.

...MODX is the Hand of the King!

You can do pretty much anything in MODX. It affords you Total Creative Freedom. With these Add-on Packages, you also have Total Cache Control.