Storage estimate does not return the correct cache storage usage
Categories
(Core :: Storage: Cache API, defect)
Tracking
()
People
(Reporter: zeroliu, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36
Steps to reproduce:
- Check the current storage usage with navigator.storage.estimate()
- Add a sized string to cache.
const str = new Array(1024*1024/4+1).join('abcd');
const response = new Response(str);
const cache = await caches.open('test');
cache.put('foo', response); - Check storage usage again
Actual results:
Usage increased by 164795 bytes
Expected results:
Usage should increase by 1MB. Chrome works as expected.
| Reporter | ||
Updated•6 years ago
|
| Reporter | ||
Comment 1•6 years ago
|
||
UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0
| Reporter | ||
Updated•6 years ago
|
Comment 2•6 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 3•6 years ago
|
||
This is most likely because cache API in firefox compresses body data.
Comment 4•6 years ago
|
||
(In reply to Xiyuan Liu from comment #0)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36
Steps to reproduce:
- Check the current storage usage with navigator.storage.estimate()
- Add a sized string to cache.
const str = new Array(1024*1024/4+1).join('abcd');
const response = new Response(str);
const cache = await caches.open('test');
cache.put('foo', response);- Check storage usage again
Actual results:
Usage increased by 164795 bytes
Expected results:
Usage should increase by 1MB. Chrome works as expected.
It's not clear to me why you expect Cache API should store 1 MB in this case. My understanding is that browsers can have their own implementations unless the spec specifies the behavior.
And, I think Ben's comment in comment 3 is correct. It's because Cache API compresses body data.
Please feel free to reopen this if you don't think so.
Description
•