Lesson 0004 · ~12 minutes · synthesis
One skill: given a feature brief, write a complete storage choice — store, shape, lifetime/isolation, and one risk you own.
This is the durable skill from
MISSION.md: defend a
sessionStorage choice (or rejection) in a design review
without hand-waving.
You can complete this from lessons 1–3 alone. External MDN/web.dev reads remain optional enrichment, not a gate.
Run in order. Earlier gates reject more options than later ones.
What must live on the client? Memory if re-fetch is fine. sessionStorage for small tab-only session state. localStorage for tiny durable prefs. IndexedDB / Cache / OPFS for their jobs. Never multi-tab bus or secrets. (Lessons 1, 3)
Methods + strings + JSON; null-guard
getItem; catch
setItem failures. No property-assignment API, no bulk
entity dumps. (Lesson
2)
Page session: reload OK, tab close clears; origin + tab partition;
iframes share, other tabs don’t;
storage events don’t cross tabs for session; opener is
a one-time copy. (Lessons
1–
2)
Probe availability; quota / disabled storage; sync main-thread thrash; no tokens; Window-only (no workers). (Lesson 3)
“We use sessionStorage | localStorage | memory | IDB | … because job + lifetime; shape is methods + JSON; isolation is tab-only / cross-tab; we own probe · quota · no secrets · no multi-tab bus.”
Keep the print playbook open after this course — compressed form of all four lessons.
Pick the best default package. Equal-length options.
Four-step checkout. Survive reload in this tab. User may open a second checkout tab that must not overwrite the first flow’s step.
Remember light/dark across browser restarts and every open tab. One string; slightly delayed apply is fine.
Cart count must update in every open tab of the shop when one tab adds an item. Count is a small integer.
Cache ~50k contact objects for offline search in any tab; a worker may pre-index. Same-origin SPA.
After login, keep a long-lived API access token so Authorization headers work after full page reload.
Re-skim web.dev — Storage for the web against this playbook’s Gate A. For lifetime details, MDN sessionStorage.