Seoxpert.io
highPerformance

HTML Pages Cached Aggressively (max-age ≥ 1 day)

HTML pages are cached for 1+ days, causing visitors to see outdated content after deploys.

By Seoxpert Editorial · Published

Why it matters

When HTML is cached too aggressively, users may not see updates or critical fixes until their cache expires. This can lead to outdated content being served, harming user experience and delaying the visibility of urgent changes.

Impact

Visitors may see stale HTML content for up to a day or more after updates are deployed.

How it's detected

The crawler inspects HTTP response headers and flags HTML pages with Cache-Control: max-age set to 86400 seconds (1 day) or higher.

Common causes

  • Server misconfiguration setting long max-age for HTML responses
  • Copying static asset cache rules to HTML endpoints
  • CDN or proxy defaulting to aggressive caching for all content types
  • Incorrect Next.js or framework cache-control overrides
  • Lack of differentiation between HTML and static asset caching

How to fix it

Set Cache-Control headers for HTML responses to 'public, max-age=0, must-revalidate' to force revalidation, or use 'max-age=60, s-maxage=600' for short browser caching and longer CDN caching. In frameworks like Next.js, review and adjust cache-control settings in next.config.ts, middleware, or revalidate options. Ensure static assets use fingerprinted URLs and are cached aggressively, but HTML is not.

Code examples

Problematic Cache-Control header for HTML

Cache-Control: public, max-age=86400

Recommended Cache-Control header for HTML (always revalidate

Cache-Control: public, max-age=0, must-revalidate

Alternative: Short browser cache, longer CDN cache

Cache-Control: public, max-age=60, s-maxage=600

FAQ

Why shouldn't HTML pages be cached for a long time?

Long caching on HTML prevents users from seeing updates or hotfixes promptly, leading to stale content.

Can I still cache static assets aggressively?

Yes, but use fingerprinted filenames for assets and only apply aggressive caching to those, not HTML.

How do I set different Cache-Control headers for HTML and assets in Next.js?

Use custom headers in next.config.ts or middleware to set short or no-cache for HTML and long max-age for assets.

What happens if a CDN is in front of my site?

The CDN may also cache HTML for too long, serving stale pages until it is purged or the cache expires.

Found this issue on your site?

Run a scan to see if HTML Pages Cached Aggressively (max-age ≥ 1 day) affects your pages.

Scan my website →