
localStorage reach maximum size while there are only 800 Kb data in it.
I met an localStorage exception when I call API "localStorage.setItem()"
we are developing a web site, we used host like aaaa.bb.com the case is :
the local storage has about 560KB Data in localstorage and then I want to set an item into localStorage, the size of the new item is 301KB
then the browser throw exception, the content of the exception is as follows:
The way I used to test the size of localStorage is: JSON.stringify(localStorage).length
"Persistent Storage maximum size reached" code:"1014" nsresult: "0x80530f6(NS_ERROR_DOM_QUOTA_REACHED)"
I tested this function in other machines and in chrome, this exception will not occur, I want to know why this exception occurs on the machine, if there is any settings in firefox? or if there is any relationship with the cache size?
Chosen solution
the root cause is found.
the reason is that aaa.domain.com and bbb.domain.com, the two sub domain will share the same space of localStorage because they are under the same top level domain domain.com.
aaa.domain.com reach maximum size when there is only 500KB data in localStorage because there is already 4.5MB data in localStorage of bbb.domain.com.
Read this answer in context 👍 4All Replies (1)
Chosen Solution
the root cause is found.
the reason is that aaa.domain.com and bbb.domain.com, the two sub domain will share the same space of localStorage because they are under the same top level domain domain.com.
aaa.domain.com reach maximum size when there is only 500KB data in localStorage because there is already 4.5MB data in localStorage of bbb.domain.com.