HomeAPI StatusFree ToolsSEO Help Articles

JavaScript Caching Test

The JavaScript Caching Test inspects the Cache-Control headers on every .js file referenced by a URL and reports whether each can be cached aggressively, briefly, or not at all. Versioned bundles (output by webpack, Vite, esbuild with content-hash filenames) can be cached for one year with the immutable directive — repeat visits become instant. Unversioned scripts must be cached more cautiously to allow updates.

What This Tool Checks

  • Cache-Control header per .js file
  • max-age and immutable directives
  • Versioned bundle detection (hashed filenames)
  • Third-party script cache policies
  • CDN cache hit ratio for JavaScript
  • ETag presence for conditional requests

Why It Matters for SEO

JavaScript bundles are often the largest single asset on a page. Caching them aggressively turns repeat visits into instant loads — zero bytes, zero parse time. Modern build tools emit content-hashed filenames so the URL changes when the content changes, making 1-year + immutable safe. Most performance issues with JS caching come from misconfigured CDN headers, not from bad build pipelines.

How to Fix It

For hashed bundles: Cache-Control: public, max-age=31536000, immutable. For unhashed scripts: shorter max-age (e.g. 1 hour) with revalidation. Audit third-party scripts and route them through your CDN where possible to control caching. Add ETag for conditional 304 responses on edge-case clients.

How It Works

We walk every <script> on the page, make a HEAD request to each src, capture the Cache-Control headers, and determine whether the URL appears versioned (hash in filename or query string). Versioning detection lets us recommend immutable safely.

Common Mistakes to Avoid

  • Versioned bundles cached for only a few hours
  • Missing immutable on hashed URLs (forces unnecessary revalidation)
  • Third-party scripts (Tag Manager, Intercom) with short cache lifetimes
  • Cache-Control: private blocking CDN caching
  • Cache-busting query strings instead of hashed filenames

Quick Checklist

  • Hashed JS bundles cached 1 year with immutable
  • Unhashed scripts cached briefly with revalidation
  • Third-party scripts cached or proxied via CDN
  • No Cache-Control: private on public scripts
  • CDN responds HIT on repeat requests

Frequently Asked Questions