Skip to content

Don't cache embedded GEDCOM in sessionStorage#308

Merged
PeWu merged 1 commit into
PeWu:masterfrom
kjiwa:session-cached-gedcom
Jun 21, 2026
Merged

Don't cache embedded GEDCOM in sessionStorage#308
PeWu merged 1 commit into
PeWu:masterfrom
kjiwa:session-cached-gedcom

Conversation

@kjiwa

@kjiwa kjiwa commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Don't cache embedded GEDCOM in sessionStorage

Summary

Embedded mode receives a fresh GEDCOM from the parent window on every load, so persisting it to sessionStorage under a constant key only ever serves a stale copy. This adds a useSessionCache opt-out to loadGedcom()/prepareData() and has the embedded data source opt out, so embedded data is never read from or written to the session cache.

Background

The in-memory store added in #296 already covers within-tab navigation, and the ready/parent_ready handshake means a page reload re-runs and the parent re-sends the GEDCOM. For embedded mode the sessionStorage layer therefore adds nothing — it's redundant with the handshake and the in-memory store.

It's also actively wrong when the GEDCOM references resources tied to the parent document. Embedded payloads can inline object URLs (blob:/data:) that become invalid once the previous document is gone. loadGedcom() caches the prepared data under the constant key embedded, and prepareData()'s existing guard only skips the write when a non-empty uploaded-images map is present — embedded mode passes an empty map (URLs are inlined in the GEDCOM text), so the guard didn't apply. On the next load the cached copy was served with dead object URLs and images broke until a hard refresh.

Change

  • loadGedcom() / prepareData() take an optional useSessionCache (default true), gating both the read and the write.
  • EmbeddedDataSource calls loadGedcom('embedded', onProgress, { useSessionCache: false }).

No behavior change for any other data source — uploaded files still use the default (cache on). The in-memory store continues to serve within-tab navigation; a reload repopulates it via the handshake.

Testing

  • New tests in load_data_store.spec.ts: caching happens by default, and with useSessionCache: false a stale entry is neither served nor overwritten.
  • npm run lint, tsc, and npm test (jest) all pass locally.

How I hit this

I run Topola Viewer behind a reverse proxy that also serves Gramps Web on the same origin; the GEDCOM is delivered to the embedded viewer via the Gramps Web API. After a reload, images failed to load until a hard refresh — the stale embedded cache entry was the cause.

@PeWu PeWu merged commit 74bef35 into PeWu:master Jun 21, 2026
4 checks passed
@PeWu

PeWu commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Thank you!

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