2

I found Home-Screen app localstorage is not deleted by Safari clear cache. It seems to be persistent storage, but I cannot find any documents about this.

My Question is

  1. Is there any document about this behavior?
  2. Home-Screen app localstorage lifecycle. when will be cleared? how to clear?
  3. Can I use localstorage to save persistent token for PWA?

There is localstorage tester here

wilfrem
  • 85
  • 5

1 Answers1

1

Local storage is not cache, it is persistent storage. You can add or delete values manually.

Apple's documentation says the following:

Safari supports the latest HTML5 offline data storage features. Your application can store its information on the local machine using either a simple key/value-based data store, or a robust SQL database. The data is stored locally and persists across launches of Safari so your application doesn’t need a network connection to access the data, improving startup time and overall performance.

This storage is limited to 5 MB and can be cleared if the device is running low on space, but this is the main way to store data on the user's device.

You can learn more about local storage here

Terren
  • 1,407
  • 1
  • 14
  • 21
  • 2
    This answer helps explain local storage in general but, the question is asked particularly about storage in home screen apps (PWA's). Is this shared with Safari? Is it documented? – Loke May 24 '19 at 12:19
  • This doesn't answer the question. Does localStorage (and cookies) 'survive' the process of being added to homescreen, like it does on Chrome/Android? – Max Waterman Aug 25 '20 at 07:12
  • 2
    From my experiments and discussions with an Apple engineer, I find that no storage is shared between the app running in-browser and from-homescreen, not even localStorage. – Max Waterman Aug 27 '20 at 04:59
  • I can confirm @MaxWaterman 's comment, I have multiple PWAs in production and this is quite a pain, especially for apps that require authentication. – Alex Suzuki Nov 25 '20 at 14:49