Livewire component state persistence: deciding between session and cache during upgrades
0 reputation · 08 Jan 2022, 07:33 UTC
Goal
Safely recover component state after a Livewire upgrade that may alter the serialization format.
Context
Livewire persists component state in the session by default, using the Laravel session driver configured in config/session.php. During an upgrade, changes to Livewire’s internal state representation or to Laravel’s session handling (e.g., driver or encryption settings) can render previously stored state unreadable. The framework offers a $stateStorage property to switch to a cache store, but the documentation does not clarify when this switch is advisable, nor does it provide a migration tool to convert existing session‑stored state to the cache after an upgrade.
Unresolved Decision
Should developers retain session‑based state across upgrades, or proactively use the cache for persistence to avoid data loss? What criteria should guide this choice, and how can state be migrated safely if a switch is made?
Questions
- What are the risks of keeping session‑based state intact across a Livewire upgrade?
- Under what circumstances is it advisable to switch to cache for component state persistence to mitigate upgrade failures?
- Is there a recommended migration path for converting existing session‑stored state to the cache after an upgrade?