From fb90349670183073ce97347f142b59be3c08ced6 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sat, 27 Jun 2026 09:40:32 +0200 Subject: [PATCH] =?UTF-8?q?docs(sbxmitm):=20plan=20=E2=80=94=20SW=20revali?= =?UTF-8?q?dation=20nudge=20(ref=20#757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plans/2026-06-27-sw-revalidation-nudge.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/superpowers/plans/2026-06-27-sw-revalidation-nudge.md diff --git a/docs/superpowers/plans/2026-06-27-sw-revalidation-nudge.md b/docs/superpowers/plans/2026-06-27-sw-revalidation-nudge.md new file mode 100644 index 00000000..e4f4c3f8 --- /dev/null +++ b/docs/superpowers/plans/2026-06-27-sw-revalidation-nudge.md @@ -0,0 +1,21 @@ +# #757 — SW revalidation nudge (strip conditional headers for allow-listed hosts) + +**Goal:** stale-while-revalidate SWs on the sw-neuter allow-list update their cache +with a banner'd shell WITHOUT being neutered — by forcing a full 200 (not a 304) +on their HTML revalidation fetch so the MITM's existing injection lands. + +**Design (approved):** in `mitmPipeline`, BEFORE the upstream proxy (`up.Do(req)`), +for an allow-listed host (`swNeuter.Match`) on an HTML document request, strip +`If-None-Match` + `If-Modified-Since` → upstream returns 200 with body → MITM +injects the banner → the SW caches the banner'd version on next background +revalidation. Gated to the allow-list (bounds the full-200 bandwidth cost). +Limitation: only helps SWs that revalidate; cache-first still needs #753's neuter. + +## Task 1 (single) +**Files:** modify `cmd/sbxmitm/swneuter.go` (add `requestWantsHTML`), `cmd/sbxmitm/main.go` (the strip); test `cmd/sbxmitm/swneuter_test.go`. + +- requestWantsHTML(req): true if `Sec-Fetch-Dest: document` (case-insensitive) OR `Accept` contains `text/html`; nil-safe false. +- Strip in mitmPipeline before `resp, err := up.Do(req)`: + `if px.swNeuter != nil && requestWantsHTML(req) && px.swNeuter.Match(host) { req.Header.Del("If-None-Match"); req.Header.Del("If-Modified-Since") }` +- Test: requestWantsHTML true/false cases (Sec-Fetch-Dest document, Accept text/html, neither, nil). +- Verify: go build + vet + go test ./cmd/sbxmitm/.