Changeset d5e78f7 in Klonkt


Ignore:
Timestamp:
06/23/2026 04:16:58 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
fe6aac9
Parents:
184393c
Message:

fix: Vary: HX-Request + no-store on partials — no unstyled page on back navigation

The browser cached an htmx partial (only #pcms-main, without <head>/CSS) under
the URL and served it on back/forward as a full page → bare HTML. Vary:
HX-Request separates partial vs full in the cache; no-store on the partial
forces a fresh full-load on back.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/render.js

    r184393c rd5e78f7  
    5757  // Decide: partial (HTMX) or full?
    5858  const isPartial = req.headers['hx-request'] === 'true' || req.query.partial === '1';
     59
     60  // Voorkom dat de browser een htmx-PARTIAL (alleen #pcms-main, zónder <head>/CSS)
     61  // onder dezelfde URL cachet en bij "terug" als volledige pagina serveert →
     62  // ongestylede HTML. Vary: HX-Request scheidt partial- en full-responses in de
     63  // cache; no-store op de partial zelf laat "terug" altijd de volledige pagina
     64  // opnieuw ophalen. (Vary geldt ook voor tussenliggende caches/Cloudflare.)
     65  res.setHeader('Vary', 'HX-Request');
     66  if (isPartial) res.setHeader('Cache-Control', 'no-store');
    5967
    6068  // Bezit deze (niet-god) user een eigen site? Bepaalt of 'ie een "Beheer"-
Note: See TracChangeset for help on using the changeset viewer.