Similar to this question, is IndexedDB guaranteed to be persistent ? ie. Safari will not reclaim disk space if the device is low on memory.
Safari have "No Eviction policy", meaning it will not automatically clean the IndexDB on low disk pressure, without user doing it manually.
IndexDB is one of the fast evolving feature and you can expect to have a different eviction policy any time with no announcement. You should always build with fall back options.
Chrome has explicit persistent storage option which will guarantee no eviction, on user approval for persistent storage and we can expect Safari to do the same sometime, based on their track record of following Chrome in implementing PWA features(though its taking years with super bad documentation).
According to this blog post from the WebKit team, IndexedDB is not guaranteed to be persistentfrom iOS and iPadOS 13.4 and Safari 13.1 on macOS. Safari will delete it after seven days of Safari usage without interaction with the site:
Now ITP has aligned the remaining script-writable storage forms with the existing client-side cookie restriction, deleting all of a website’s script-writable storage after seven days of Safari use without user interaction on the site. These are the script-writable storage forms affected (excluding some legacy website data types):
- Indexed DB
- LocalStorage
- Media keys
- SessionStorage
- Service Worker registrations and cache
However, IndexedDB is pretty much guaranteed to be persistent if your Web app is installed in your Home Screen, as the Web app will have its own usage context, and due to its very nature, it'd be impossible to use it for seven days without accessing the site where it came from:
[...] Web applications added to the home screen are not part of Safari and thus have their own counter of days of use. Their days of use will match actual use of the web application which resets the timer. We do not expect the first-party in such a web application to have its website data deleted.
Regardless of the above, I would personally not trust IndexedDB for any kind of long-term data storage. I've found it quite ropey, and not long ago broke altogether in Safari 14.1.1.
I have no definitive answer, but after using IndexedDB for over 2 years in a big browser/desktop (electron based) application I would attribute multiple datalosses to IndexedDB or at least IndexedDB in chrome. So my answer would be no. Don't rely on it.
© 2022 - 2024 — McMap. All rights reserved.