Skip to Content
Piplup
@piplup/vite-plugin-cache-buster

Installation — @piplup/vite-plugin-cache-buster

Install the Vite plugin that generates a release ID at build time, so @piplup/cache-buster can reload clients running a stale bundle.

@piplup/vite-plugin-cache-buster generates a release ID during your Vite build, enabling @piplup/cache-buster to detect new deployments and refresh stale client caches.

npm install @piplup/vite-plugin-cache-buster

Setup

Add the plugin to your Vite config:

import { vitePluginCacheBuster } from '@piplup/vite-plugin-cache-buster';

export default {
  plugins: [vitePluginCacheBuster()],
};

How it works

At the start of a production build, and when the dev server starts, the plugin:

  • Generates a unique release ID
  • Writes it to public/RELEASE (set publicDir to use another folder)
  • Leaves Vite to copy it to the output, so the deployed site serves it at /RELEASE

@piplup/cache-buster fetches this file to detect updates. The file changes on every build, so add public/RELEASE to .gitignore. For the whole setup, see Reload users after a deploy.

Why this is required

Cache busting relies on comparing:

  • Current release ID (from server file)
  • Stored release ID (in browser storage)

Without generating this file during build, the app cannot detect updates.

When to use

Use this plugin if:

  • You're using Vite
  • You're using @piplup/cache-buster
  • You want automatic release ID generation

Next step

Integrate the runtime check — use useReleaseStatus or <CacheBuster /> in your app.

See also

On this page