Skip to content

Conversation

@adamziel
Copy link
Collaborator

@adamziel adamziel commented Jan 28, 2026

Summary

This is a potential fix for intermittent Safari PWA failures after deployments where the site displays a blank page until the cache is manually cleared.

Theory: Safari sometimes adds Range headers to asset requests, causing servers to return 206 Partial Content responses. These partial responses fail when using Cache.put() because the Cache API requires complete responses.

The Problem

After deploying playground.wordpress.net, Safari users sometimes experience:

  • Blank page on reload, even though assets like main.js are accessible
  • The files exist and load fine in new tabs
  • Only clearing the cache and reloading fixes it
  • Chrome and Firefox work fine with the same network-first caching strategy

The Fix

Strip the Range header from requests before fetching in cacheFirstFetch(). This ensures:

  • Servers return 200 OK with complete responses instead of 206 Partial Content
  • Responses can be successfully cached with Cache.put()
  • Consistent behavior across all browsers

Important Note

This is a best-guess fix since the issue is not easily reproducible outside the deployed production environment. The Safari-specific behavior with Range headers in PWA contexts is well-documented, and this fix addresses that known issue. However, the root cause of the blank page problem may be more complex.

Testing

The change is defensive and shouldn't affect normal operation:

  • If no Range header is present, the request passes through unchanged
  • If a Range header exists, a new request is created without it
  • All other headers and request properties are preserved

Safari sometimes adds Range headers to asset requests in PWA contexts,
causing servers to return 206 Partial Content responses. These partial
responses can't be cached using the Cache API's .put() method, leading
to cache failures.

This appears to be related to intermittent Safari issues where the PWA
fails to load after deployments, displaying blank pages even though the
assets are accessible. While the root cause is difficult to reproduce
outside production, stripping Range headers ensures full 200 OK responses
that cache correctly.

The fix creates a new Request without the Range header before fetching,
allowing the cacheFirstFetch strategy to work properly across all browsers.
@adamziel adamziel changed the title Fix Safari PWA cache failures by stripping Range headers [Website] Fix Safari PWA cache failures by stripping Range headers Jan 28, 2026
@adamziel adamziel merged commit 330c0c0 into trunk Jan 28, 2026
35 checks passed
@adamziel adamziel deleted the fix-safari-range-header-cache-issue branch January 28, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants