Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Assetic Cache Busting Worker Laravel Package

jeroenvdheuve/assetic-cache-busting-worker

A PHP worker for Assetic that adds cache-busting to asset URLs by appending content-based versions or hashes. Helps prevent stale browser caches after deployments by keeping generated asset references in sync with compiled files.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is archived (last release 2015, 0 stars, 0 dependents). The only realistic audience is a team maintaining a legacy Symfony 2.x / Assetic application. If you are starting fresh, stop here and use Symfony Encore, Vite, or Webpack instead — symfony/asset + symfony/webpack-encore-bundle covers cache busting today.

For a legacy app:

  1. Install from source (Packagist resolution may be flaky). Prefer a path or VCS repository entry:
    "repositories": [{"type": "vcs", "url": "https://github.com/jeroenvdheuvel/assetic-cache-busting-worker"}]
    
    Then composer require jeroenvdheuve/assetic-cache-busting-worker:dev-master.
  2. Look first at vendor/jeroenvdheuvel/assetic-cache-busting-worker/src/ and open the class that implements Assetic\Factory\Worker\WorkerInterface. There is no documentation shipping with the repo, so the interface methods (process() / getHash()) are your spec.
  3. First use case: register the worker on your Assetic\Factory\AssetFactory so that every compiled asset gets a content-hash fingerprint appended to its URL, invalidating browser caches on deploy without changing template code.

Implementation Patterns

Register on the AssetFactory. Assetic workers run at factory time, before the asset is dumped:

use Assetic\Factory\AssetFactory;
use JeroenVdHeuvel\Assetic\Worker\CacheBustingWorker; // adjust to actual FQCN

$factory = new AssetFactory($rootDir);
$factory->setDebug(false);
$factory->addWorker(new CacheBustingWorker(/* ctor args from source */));

Symfony 2 service overlay. Decorate the assetic.factory service in services.yml rather than instantiating manually:

services:
    assetic.factory:
        class: Assetic\Factory\AssetFactory
        # ... existing args ...
        calls:
            - [addWorker, ['@app.assetic.cache_busting_worker']]

    app.assetic.cache_busting_worker:
        class: JeroenVdHeuvel\Assetic\Worker\CacheBustingWorker

Template-side usage stays unchanged. The whole point of a worker is that {% stylesheets %} / {{ asset('...') }} resolve to the busted URL automatically. If you find yourself editing Twig tags to add ?v= by hand, the worker is not registered correctly.

Pair with the core worker as a fallback. Assetic\Factory\Worker\CacheBustingWorker ships in Assetic itself. If this package's behaviour (e.g., a specific hash algorithm or file naming) doesn't match what you need, the bundled one is a known-good substitute and is still maintained.

Run inside the dump pipeline. Ensure assetic:dump executes in your CI/deploy so the hash reflects the built output, not source files. The worker only computes a value; the dump is what produces the fingerprinted artifact.

Gotchas and Tips

  • It is archived and unmaintained. No security fixes, no PHP 7/8 compatibility guarantees. Audit the source against your PHP version before shipping; the 2015 code is very likely PHP 5.x syntax.
  • Composer autoload may be PSR-0. Older Assetic-era packages often use psr-0 in composer.json. If classes can't be found, check the autoload block and add a psr-4 override via your root composer.json.
  • Worker ordering matters. AssetFactory::addWorker() appends in insertion order; workers run sequentially. If you stack a minifier worker and a cache-buster, verify the buster runs after the minifier so the hash is computed over final content.
  • Debug mode bypasses fingerprinting. With assetic.debug: true the factory emits un-fingerprinted URLs by design. Test cache busting against dev with debug off, or only in prod.
  • Hash stability across machines. If the worker derives the hash from file mtime or a random salt, two deploys of the same content can produce different URLs — a common source of CDN cache thrash. Prefer a content hash and, if the package doesn't offer it, subclass and override getHash().
  • Clearing assetic:dump output is required. Stale fingerprinted files linger in web/ after deploy. Add a rm -rf web/{css,js}/* or assetic:dump --force step.
  • Extension point: the cleanest upgrade path is to subclass the worker and override the hash computation (e.g., git rev-parse --short HEAD for a build ID), keeping the packaged class as a thin shell.
  • Symfony 2 bundle bridge is gone. If you're on Symfony 3+, the AsseticBundle config keys changed and the assetic.asset_factory service ID may differ — verify with debug:container | grep assetic before wiring.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin