Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Possible to use a single cache? #86

Closed
gauntface opened this issue Feb 18, 2016 · 6 comments
Closed

Possible to use a single cache? #86

gauntface opened this issue Feb 18, 2016 · 6 comments
Milestone

Comments

@gauntface
Copy link

Chatting with one of the engineers and the topic of using multiple caches (i.e. one per asset) could be poor in terms of the number of instances of caches in memory at any one time.

Is there a specific reason precache couldn't use a single cache?

@pb6110
Copy link

pb6110 commented Feb 19, 2016

im not sure

@jeffposnick
Copy link
Contributor

I had informally run the idea of multiple caches by some of the Chrome engineers during initial development, and there weren't any red flags raised at the time. But I wouldn't be surprised if there are yellow flags, and it's admittedly an ugly hack that I'd rather avoid.

When sw-precache launched, I recall that there wasn't native support for cache.match(), and the polyfill was O(N), which made the performance poor in some early experimentations that used a single cache with a large set of resources. That's not an issue anymore.

More of an issue now is the best way to store the MD5 fingerprint metadata as part of a Request object's URL. We could synthesize a new Request object and append a URL parameter like sw-precache-fingerprint=<MD5> to the real URL without too much of a risk of breakage, I think, but it's not a trivial change, and it wouldn't be backwards compatible with any previous cache entries. But it seems like a viable solution, unless anyone has other ideas.

See w3c/ServiceWorker#657 (comment) for some related discussion of storing metadata for cache entries.

@jkarlin
Copy link

jkarlin commented Apr 21, 2016

cache.match() is fast now, but operations on a single cache run sequentially (there is a todo to make this parallel where possible) so it's possible you'll see performance degradation compared to lots of caches running in parallel

@gauntface
Copy link
Author

Counter argument to that: at the moment sw-precache has to intercept the
fetch request and find the correct cache first.

On Thu, 21 Apr 2016, 19:21 Josh Karlin, [email protected] wrote:

cache.match() is fast now, but operations on a single cache run
sequentially (there is a todo to make this parallel where possible) so it's
possible you'll see performance degradation compared to lots of caches
running in parallel


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#86 (comment)

@jeffposnick
Copy link
Contributor

Finding the correct cache is done via an in-memory Object mapping that should complete quickly and synchronously, though.

@jkarlin
Copy link

jkarlin commented Apr 21, 2016

I think you should use a single cache. And then complain if the performance degrades :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants