Re: [ServiceWorker] consider exposing size for cache entries (#587)

@robrbecker your tl;dr is longer than the OP! But the extra detail is really valuable, thanks for the use-case and clarification.

> the user would want to see the space actually consumed on disk, including request overhead and taking into account compression, etc

The UA may dedupe across caches to save disk space. I don't think this is a huge issue, but we should nod to it in the spec.

> not only the size of individual items in the cache

In fact, the cache size is going to be more accurate than the `content-size` header which may be absent or completely false. An accurate way would be `response.arrayBuffer().then(a => a.length)`, but that would be pretty horrific for performance.

@robrbecker what's more important, the size of individual items or the size of the whole cache?

@wanderview would it be simpler to have a single `cache.size()` promise-returning method? If we need a way to query the size of multiple cache entries maybe we should change the resolve-type of `.matchAll` to be something that extends `Array`, so it would be `cache.matchAll(request).then(rs => rs.totalSize())` or something.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/587#issuecomment-73487407

Received on Monday, 9 February 2015 10:33:43 UTC