spekkionu/assetcachebuster
A Laravel package that adds cache-busting version strings to asset URLs, helping browsers load updated CSS and JavaScript after deployments. It integrates with Laravel's asset helper and supports configurable versioning for reliable cache invalidation.
mix() existed. On 5.4+ the "borrow the pattern, use the native API" answer still wins.max-age/immutable caching and CDN edge caching; the decision to set aggressive cache headers is only safe once you have a versioning mechanism. This package makes that trade-off explicit and cheap to test.Consider it when:
public/ with long-lived cache headers and you need per-deploy invalidation with minimal configuration.Look elsewhere when:
mix()) or Laravel 9+ (Vite) — native content-hashed URLs already solve this with first-party support, zero extra dependency, and SRI/manifest support. Note that v2.0.0 does not change this: it targets 5.x, not 5.4+'s Mix workflow, so it is not a substitute for mix().To executives (one paragraph): We occasionally ship a release and a slice of users keep seeing the old stylesheet or script until they hard-refresh. It is not an outage, but it generates support tickets and erodes trust in releases. The fix is a well-understood technique — give each asset URL a release-specific prefix so browsers treat it as a new file. A small MIT-licensed package does this in an afternoon, and its latest release extends support to Laravel 5, which covers our older apps without a modern build step. Two caveats: the package itself is from 2015 with a single maintainer and no recent releases, and the new version is a major bump rather than a routine patch. So my recommendation stands — adopt the pattern via the framework's built-in asset versioning where we are on Laravel 5.4+, and reserve this package for the pre-Mix legacy app where no build step exists. Cost either way is measured in hours, not weeks; the decision is low-risk and easy to reverse. The release does not change that calculus; it slightly widens where the stopgap is technically viable.
To engineering: The mechanism is simple and side-effect-free — rewrite emitted asset URLs with a build/deploy hash, leave files and cache headers untouched. Integration is a Blade/helper-level change, no runtime dependency beyond the hash source. What v2.0.0 changes is the compatibility floor only: Laravel 5 is now supported, so the package is in-scope for 5.0–5.3 projects that previously had no supported option. It does not make it a replacement for mix() on 5.4+, and a major version bump means an explicit v1 → v2 review rather than a composer update. Three caveats to weigh: (1) it remains unmaintained since the mid-2010s, so pin the version (v2 for 5.x, v1 for 4.x), vendor or fork it, and add a smoke test asserting the hash changes between builds; (2) if we are on Mix or Vite, use mix()/@vite instead and treat this repo as documentation; (3) if we adopt it, pair it with immutable cache headers and a retained-artifacts policy so rollbacks keep old hashed URLs resolvable — otherwise we have added a dependency without capturing the reliability win.
How can I help you explore Laravel packages today?