当localStorage已满时会发生什么? [英] What happens when localStorage is full?
问题描述
我已经找到关于缓存行为的文章,所以我只能假设它没有太大的不同,但我想确保。
我已经读过,大多数浏览器有5MB(给或拿)localStorage,我是intrested浏览器的行为是什么?
我明白每个浏览器的行为不同,但我主要在Safari,Chrome和Firefox中感兴趣(因为那些是我认为的作为浏览器)。
- 上面提到的浏览器是否会从我的网站上删除数据,或者会选择最老的还是某种类型的?
- 在这种情况下我的物品会被保存吗?
:b 可以说我滥用localStorage和我的网站试图使用它,并在同一页 如果我尝试保存大于localStorage大小的项目,会发生什么情况? 已解答: answer can找到这里 是否可以从sessionStorage中得到相同的确切的行为,这应该是相同的吗? 我知道这是很多问题,但我试图理解所有与这个主题有关的东西,我会感谢你能回答的问题的任何部分。 / p> Regards。 首先,介绍一些有用的资源: 在回答你的问题时,桌面浏览器往往有一个初始的最大localStorage配额每个域5MB。在某些情况下,用户可以对此进行调整: 在Chrome中,似乎没有尽管像Opera,localStorage数据可以使用开发工具在每个域直接编辑。 当您尝试在localStorage中存储数据时,浏览器检查当前域是否有足够的剩余空间。 在这种情况下, (Opera略有不同,它会显示一个对话框,让用户选择增加当前域的存储空间。)注意sessionStorage和localStorage都是相同的存储对象的实现,所以他们的行为是相似的,错误处理是相同的。 I have found articles regarding cache behaviour so i can only assume that it's not much different but i wanted to make sure. I have read that most browser have 5MB (give or take) for localStorage and i was intrested in what would be the behaviour of the browsers? I understand every browser acts diffrently but i'm intrested mostly in Safari, Chrome and Firefox (as those are the ones i consider as browsers). And the most important : Lets say i "abuse" the localStorage and my website trying to use it all up, and in the same page
i'm filling it up and trying to save more, will i get a warning AND will the What happens if i try and save an item larger then the localStorage size? Answered : answer can be found here Is the same exact behaviour can be expected from sessionStorage which allegdly should be the same? I know this is alot of questions but i'm trying to understand all that's related to the subject, i'd be thankfull for any part of the question you can answer. Regards. Firstly, some useful resources: In answer to your question, desktop browsers tend to have an initial maximum localStorage quota of 5MB per domain. This can be adjusted by the user in some cases: In Chrome, there doesn't seem to be a way for the user to adjust this setting although like Opera, localStorage data can be edited directly per domain using the Developer Tools. When you try to store data in localStorage, the browser checks whether there's enough remaining space for the current domain.
If yes: If no: In this case, (Opera is slightly different in that it displays a dialog box giving the user the choice of increasing storage space for the current domain.) Note that sessionStorage and localStorage are both implementations of the same Storage object so their behaviour is similar and error handling is the same. 这篇关于当localStorage已满时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b
我正在填充它,并试图保存更多,我会得到一个警告和会发生这种情况或以某种方式保存在内存中 getItem
返回null
Storag e Support Test(支持测试) - 有一个表格,用于比较浏览器之间的数据存储配额
。
localStorage配额测试
如果是:
QUOTA_EXCEEDED_ERR
异常
getItem(key)
将返回成功存储的最后一个值(如果有的话)。
getItem
return null when this happens or it somehow saved in memory?
QUOTA_EXCEEDED_ERR
exception is thrown.getItem(key)
will return the last value that was successfully stored, if any.