⏱ 1 min read
Cache Buster
What it does: Automatically appends a unique build timestamp to your CSS file references to ensure browsers always load the latest version of your styles.
Events: CREATE (priority 10)
How it works:
- During the
CREATEevent, the feature generates a uniquebuild_idbased on the current timestamp. - This
build_idis stored in the container, along with acache_bustervariable (formatted assfcb=TIMESTAMP). - In your Twig templates, you can append
?{{ cache_buster }}to your asset URLs.
Example Usage:
In your base.html.twig:
<link rel="stylesheet" href="assets/css/main.css?{{ cache_buster }}">
Result:
The rendered HTML will look like:
<link rel="stylesheet" href="assets/css/main.css?sfcb=1732134567">
This forces the browser to treat the file as a new resource whenever you rebuild your site, preventing stale cache issues.