Jump to main content Jump to doc navigation

Cachebuster allows you to easily control whether or not assets are loaded fresh from the server or versioned by a site version setting. Simply append the smartcache Chunk to the end of your asset URLs as seen below.

Using Cachebuster

<link rel="stylesheet" href="[[++assets_url]]css/styles.css?nc=[[$smartcache]]">

If the cb.cachebust``System Setting is enabled the asset will never be cached by the browser. If disabled, it will return the current version of the website obtained from the cb.site_ver System Setting. Adding the site version to the URL will ensure that when changes pushed to production returning visiting aren't loading stale files from their browser cache.

Optional Settings

Placeholder

Cachebuster can set to a placeholder rather than returning a value. Simply pass the name of the placeholder you'd like to use as seen below.

[[$smartcache? &placeholder=`cbtime`]]

Appending Paramater

To append a URL parameter to the result use the param paramater as seen below.

[[$smartcache? &param=`?cb`]]

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • eydolan
  • Following Sea
  • Lefthandmedia
  • Murray Wood
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$311 per month—let's make that $500!

Learn more