According to https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/persist you can mark a box as "persistent" as follows:
if (navigator.storage && navigator.storage.persist)
navigator.storage.persist().then(function(persistent) {
if (persistent)
console.log("Storage will not be cleared except by explicit user action");
else
console.log("Storage may be cleared by the UA under storage pressure.");
});
According to https://developer.mozilla.org/en-US/docs/Web/API/Storage_API:
"If a box is marked as "persistent", the contents won't be cleared by the user agent without either the data's origin itself or the user specifically doing so. This includes scenarios such as the user selecting a "Clear Caches" or "Clear Recent History" option. The user will be asked specifically for permission to remove persistent site storage units."
However, clearing recent history in Chrome and Firefox removes the data without asking me for permission. What did I miss?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…