[w3c/ServiceWorker] Get Cache Size (#1059)

I wish we had a simple method to get how much cache is used from a specific cache.

- Using `blob.size()` on each response from the cache isn't what I want as it uses the uncompressed size. 
- Using `content-length` headers is not reliable either as it is not always present. Even so, I'd have to concatenate all response headers (with some extra characters) and content-length headers which won't match exactly what is in the cache.

See my simple proposal. 

```js
caches.open('my-cache')
.then(cache => cache.getSize())
.then(cacheSize => console.log('My cache is about ' + cacheSize + ' Bytes'));
```

@jakearchibald WDYT?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1059

Received on Friday, 20 January 2017 15:20:46 UTC