⏱ 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:

  1. During the CREATE event, the feature generates a unique build_id based on the current timestamp.
  2. This build_id is stored in the container, along with a cache_buster variable (formatted as sfcb=TIMESTAMP).
  3. 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.