Skip to content
Content is incomplete and some pages may be missing or low quality. Check back soon for updates.

Cache Busting

Cache busting is a technique used to ensure that users always receive the latest version of a file, even when browsers or CDNs aggressively cache assets. Without it, updates to images, scripts, or stylesheets may not appear immediately because older versions are still stored in cache.

ghettocdn solves this by generating unique, versioned filenames for your assets during the build process. Instead of serving a file like:

/images/logo.png

it produces something like:

/images/logo.a1b2c3.png

The added hash is based on the file’s contents. If the file changes, the hash changes too, which results in a completely new filename. Since the URL is different, browsers and CDNs treat it as a new resource and fetch it immediately instead of relying on a cached version.

To keep things manageable, ghettocdn maintains a manifest.json file that maps your original canonical filenames to their versioned equivalents. This allows you to reference assets using stable, predictable stubs in your code, while helper libraries or build tools resolve them to the correct versioned paths at runtime or build time. You can read more about the structure of the manifest.json file here.

In some cases, you may not want certain files to be cache busted. ghettocdn allows you to exclude specific assets using the hash_ignore configuration field. This field accepts a list of file stubs, and any matching files will retain their original filenames without a content hash. You can read more about configuring this behavior here.

In short, cache busting ensures:

  • Users always receive the latest version of your assets
  • Cached files can still be used safely when unchanged
  • You avoid manual cache invalidation or cache clearing strategies