Skip to content

Fix HTML caching in service worker#448

Merged
theg1239 merged 2 commits into
devfrom
main
Jun 18, 2026
Merged

Fix HTML caching in service worker#448
theg1239 merged 2 commits into
devfrom
main

Conversation

@theg1239

Copy link
Copy Markdown
Member

No description provided.

cursoragent and others added 2 commits June 17, 2026 11:02
Co-authored-by: theg1239 <theg1239@users.noreply.github.com>
…n-e09c

fix: avoid caching HTML in service worker
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examcooker-dev Error Error Jun 18, 2026 12:38am

@theg1239
theg1239 merged commit afcee38 into dev Jun 18, 2026
3 of 5 checks passed
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

  • Updates the service worker cache version and cache policy for HTML responses.
  • Handles HTML navigations through the network while preserving the offline fallback path.
  • Prevents native route prefetches from writing uncacheable page routes into the page cache.
  • Adds a standalone service worker cache-policy regression test script.

Confidence Score: 3/5

The service worker caching direction is sound, but the cache-policy guard is not part of the normal validation path and the prefetch loop changes request pacing.

The changed surface is small and focused, with a targeted standalone regression check, but the remaining issues can allow regressions to pass unnoticed and can alter runtime prefetch behavior.

scripts/test-service-worker-cache-policy.mjs and public/sw.js

T-Rex T-Rex Logs

What T-Rex did

  • Reproduced the CI build path and confirmed the normal npm build validation omits the service worker cache policy script; the standalone test script runs and passes when invoked directly.
  • Ran the service worker prefetch pacing harness against the public/sw.js and observed that the /mod route was skipped as uncacheable and /notes arrived earlier than the 240ms pacing (120ms after /).
  • Compared the HTML fetch handler behavior before and after changes; the before path used staleWhileRevalidate and cached one item, while the after path uses networkOnlyWithOfflineFallback and cached nothing.
  • Compared offline fallback behavior; the after path returned 200 OK with the offline fallback body and did not cache the failed HTML, unlike the before path.
  • Reviewed prefetch no-persist sequences; the before artifact showed caches opened and cache puts for "/" and "/notes", while the after artifact showed zero caches.open and zero cache.put calls.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (1)

  1. public/sw.js, line 105-111 (link)

    P2 Keep prefetch pacing

    This continue skips the existing await wait(120) throttle for uncacheable routes. The current native prefetch list includes /mod in the skipped set, so /notes can be fetched immediately after / instead of preserving the per-route pacing. When more skipped routes are present, the service worker can burst the remaining prefetches instead of spacing them out.

    Artifacts

    Repro: service worker prefetch pacing harness

    • Contains supporting evidence from the run (text/javascript; charset=utf-8).

    Repro: prefetch trace output showing missing wait for skipped route

    • Keeps the command output available without making the summary code-heavy.

    View artifacts

    T-Rex Ran code and verified through T-Rex

    Fix in Codex Fix in Claude Code Fix in Cursor

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (1): Last reviewed commit: "Merge pull request #446 from ACM-VIT/cur..." | Re-trigger Greptile

Comment on lines +177 to +179
await testHtmlNavigationIsNetworkOnly();
await testHtmlNavigationKeepsOfflineFallback();
await testNativePrefetchDoesNotPersistPages();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Wire test into CI

This new regression test is not invoked by any package script or workflow, so it will not run during the normal build checks. A future change can reintroduce HTML caching or prefetch persistence while CI still passes. Please add a package script for this file and run it from the existing CI/build check path.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Artifacts

Repro: normal npm build validation output omits the service worker cache policy script

  • Keeps the command output available without making the summary code-heavy.

Repro: CI-equivalent install and build attempt timed out during dependency installation

  • Keeps the command output available without making the summary code-heavy.

Repro: standalone service worker cache policy script passes when invoked directly

  • Keeps the command output available without making the summary code-heavy.

View artifacts

T-Rex Ran code and verified through T-Rex

Fix in Codex Fix in Claude Code Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants