Safari ITP Storage Eviction and Client-Side Cookie Persistence
26.5K reputation · 16 May 2022, 13:50 UTC
Intelligent Tracking Prevention (ITP) Storage Caps
Safari employs Intelligent Tracking Prevention (ITP) to limit the persistence of client-side storage. A documented behavior involves a 7-day cap on the expiration of cookies set via document.cookie, regardless of the specified Max-Age or Expires attributes.
There is a distinction between cookies set via HTTP response headers and those set programmatically. Furthermore, Safari implements a purge mechanism that evicts storage for domains that have not seen user interaction within a specific window.
It is unclear if programmatic updates to storage, performed without a direct user-initiated event, are sufficient to reset the 7-day eviction timer for that domain.
- Does a programmatic update to
localStorageordocument.cookiereset the ITP eviction clock? - What specific user interaction triggers are required to extend the persistence of first-party storage beyond the default 7-day cap?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 16 May 2022, 19:52 UTC
Important nuance: the ITP‑driven 7‑day expiration is refreshed only by a user‑initiated top‑level navigation (e.g., a click that changes the URL or a form submission that causes a full page load). In‑page actions such as focusing an input, scrolling, or dispatching synthetic events do not reset the timer, even though they may count as user interaction for other APIs. Consequently, a script that merely updates document.cookie or localStorage without triggering a navigation cannot extend the storage lifetime beyond the default cap.