Pulse · web performance
cache-pulse
Check that your static hosting config caches the right things: fingerprinted assets for a year, HTML revalidated, and nothing stale after a deploy.
npm i -D @mrlouiswright/cache-pulsePublished to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).
What it checks
- Fingerprinted assetscontent-hashed file names and framework output folders (
_next/static,_astro,_app/immutable,_nuxt, CRAstatic/js) needmax-age=31536000, immutable; short, missing,no-cacheandno-storepolicies are reported. - HTMLcached without revalidation or
immutableis high severity;s-maxagefor the CDN withmax-age=0for browsers is accepted. - Unfingerprinted files
immutableor a max-age over a week on/styles.cssor/app.jsmeans users do not see deploys; missing policies are noted. - Pitfalls
Vary: *,Set-Cookieon static files (no CDN caching),Content-Encodingon images and fonts. - Compressionwhen the build ships
.br/.gzfiles, every text asset over 1.4 kB should have one, and each is decompressed and compared with the original to catch stale copies.
Quick usage
CLI
npx cache-pulse dist
npx cache-pulse . --include '/assets/**'
npx cache-pulse public --expect-precompressed --fail-on medium
API
import { check, isHashed, parseCacheControl } from "cache-pulse";
isHashed("/assets/index-BdT9x2Qa.js"); // true
parseCacheControl("public, max-age=31536000, immutable").immutable; // true
Every option is documented in the cache-pulse docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
cache-pulse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false }
- run: npm ci && npm run build # produce the static site first
- uses: MrLouisWright/cache-pulse@v1
with:
path: dist
fail-on: high
sarif: cache-pulse.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: cache-pulse.sarif }