Cache Override, an ExpressionEngine plugin

Cache Override is a flexible ExpressionEngine plugin that provides cache-busting URLs for requested assets.

In order to provide cache-busting URLs for assets, I used PHP at the top of the page to grab the last-modified timestamp of the file, then an echo to output that timestamp in the appropriate places. So, to get this done, I needed the same PHP on the top of every page, and I needed to add a new line for every asset I wanted to cache-bust.

Not exactly elegant.

At one point, I used a build script to create an embeddable file with the cache-busted URL in it. This file would have to be uploaded along with the updated file-to-be-requested, and for the sake of organization, it lived in an entirely different directory.

Again with the lack of elegance.

Enter my friendly ExpressionEngine plugin, Cache Override.

Cache Override works a lot like EE's built-in {path} variable in that it outputs a URL based on the provided path, but it comes with a few extra features:

Both the pattern and absolute_url are optional, providing simple defaults, if you're not interested in these parameters cluttering up your code. (Hey, that is a valid concern, no need to blush.)

The pattern parameter is key to Cache Override's utility, in two ways:

  1. Relying on a timestamp in a query string prevents proxy browsers from caching the asset for its users. Cache Override allows you to employ the "revving the filename" technique.
  2. The pattern provides flexibility in how you set your server's rewrite rules, putting more control in your or your team's hands.

Example usage:

{exp:cache_override path="/assets/css/styles.min.css" pattern="v-{t}.{f}.{e}" absolute_url="true"}




General resources for cache busting: