
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
Auto-add content-hash cache-busting query params (?v=hash) to HTML static file references. Zero dependencies.
Auto-add content-hash cache-busting query params to HTML static file references. Zero dependencies.
Before: <link href="/static/style.css?v=6">
After: <link href="/static/style.css?v=39258372">
No more manually bumping ?v=6 to ?v=7. ver2 reads the actual file content, computes an MD5 hash, and updates the query param automatically. If the file hasn't changed, the hash stays the same.
If you serve static files with vanilla HTML (no Webpack, no Vite) and your CDN caches aggressively (looking at you, Cloudflare), you need cache-busting. The existing npm packages are either abandoned, require special HTML attributes, or only rename files.
ver2 does one thing well: scan HTML, hash files, update ?v=.
npm install -g ver2-cli
Or use directly with npx:
npx ver2-cli ./public
# Basic: scan all HTML files in a directory
ver2 ./public
# Preview changes without writing
ver2 ./public --dry-run
# URL prefix mapping (e.g. Fastify/Express static prefix)
ver2 ./public --strip /static/
# Custom hash length (default: 8)
ver2 ./public --length 12
# Custom query param name (default: v)
ver2 ./public --param hash
If your HTML references /static/style.css but the file lives at ./public/style.css (common with Fastify/Express static serving), use --strip:
# Strips /static/ from URLs before looking up files
ver2 ./public --strip /static/
For advanced cases where the static directory differs from the target:
# /assets/main.js -> look in ./dist/assets/main.js
ver2 ./public --prefix /assets/ ./dist/assets
ver2 v0.1.0
index.html
/static/style.css ?v=6 -> ?v=39258372
/static/app.js ?v=6 -> ?v=27362df0
dashboard.html
/static/style.css ?v=6 -> ?v=39258372 (unchanged)
/static/dashboard.js ?v=6 -> ?v=30be3214
2 files scanned, 3 updated, 1 unchanged
import { ver2 } from 'ver2-cli'
const results = ver2('./public', {
prefixMap: { '/static/': '.' },
dryRun: false,
hashLength: 8,
paramName: 'v',
})
for (const file of results) {
console.log(file.relativePath, file.updates.length, 'references updated')
}
Add to your package.json:
{
"scripts": {
"cachebust": "ver2 ./public --strip /static/"
}
}
Or use in a CI build command:
npm install && npx ver2-cli ./public --strip /static/
.html files in the target directorysrc="..." and href="..." attributeshttps://, //, data:, etc.)?v={hash} or replaces existing ?v= valueProperties:
?v= param| Flag | Description | Default |
|---|---|---|
--dry-run | Preview changes without writing | false |
--strip <prefix> | Strip URL prefix before resolving | — |
--prefix <url> <dir> | Map URL prefix to directory | — |
--param <name> | Query parameter name | v |
--length <n> | Hash length in characters | 8 |
--ext <list> | File extensions to scan (comma-separated) | .html |
--verbose | Show detailed output | false |
ver2 hashes references to these static file types:
.js .css .png .jpg .jpeg .gif .svg .ico .webp .avif .woff .woff2 .ttf .eot .mp3 .mp4 .webm
MIT
FAQs
Auto-add content-hash cache-busting query params (?v=hash) to HTML static file references. Zero dependencies.
We found that ver2-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.