Download the PHP package purplespider/silverstripe-assets-cachebusting without Composer
On this page you can find all versions of the php package purplespider/silverstripe-assets-cachebusting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download purplespider/silverstripe-assets-cachebusting
More information about purplespider/silverstripe-assets-cachebusting
Files in purplespider/silverstripe-assets-cachebusting
Package silverstripe-assets-cachebusting
Short Description Automatic cache busting for SilverStripe assets by appending file hash to URLs
License BSD-3-Clause
Informations about the package silverstripe-assets-cachebusting
SilverStripe Assets Cache Busting
Automatic cache busting for SilverStripe assets by appending file content hash to URLs.
Overview
This module adds automatic cache busting to all asset URLs in SilverStripe by appending a unique parameter based on the file's content hash. This allows you to set aggressive browser cache headers (long expiry times) while ensuring browsers and CDNs (like Cloudflare) fetch updated files when they change.
Solves a common problem: When a CMS user replaces an asset with a new file using the same filename, CDNs and browsers can serve the old cached version for hours or days. This module ensures the URL changes automatically when the file content changes, forcing immediate updates.
Before:
After:
When the file content changes, the hash automatically updates, forcing browsers to fetch the new version.
Version Compatibility
| Module Version | SilverStripe Version | Assets Version |
|---|---|---|
| 1.x | 5.x | 2.x |
| 2.x | 6.x | 3.x |
For SilverStripe 5: Use version 1.x
For SilverStripe 6: Use version 2.x (current)
Installation
Install via Composer (will install the version compatible with your SilverStripe installation):
Then run dev/build:
SilverStripe 5:
SilverStripe 6:
Configuration
Cache busting is enabled by default. To disable it, add this to your config:
How It Works
The module automatically appends a unique hash parameter to all asset URLs. The hash is based on the file's content, so it changes whenever a file is replaced - even if the filename stays the same.
This works everywhere: file links, images in WYSIWYG content, template references, resized images, and more. When a CMS user replaces an asset, Cloudflare and other CDNs immediately serve the new version.
Credits
Based on SilverStripe Framework PR #2402 by @patbolo.
License
BSD-3-Clause. See LICENSE for details.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.