Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workbox-precaching and workbox-cache-expiration could use the same IDB database name. #1398

Closed
philipwalton opened this issue Mar 28, 2018 · 1 comment

Comments

@philipwalton
Copy link
Member

Library Affected:
workbox-precaching, workbox-cache-expiration

Both of these modules use the cache name as the IDB name, but this means if I pass the cache expiration plugin to precache.activate(), it errors because the names are the same.

I think all packages that create IDB databases should (wherever possible) use the package name as the IDB database name. If more than one database is needed, then we can use the package name as a prefix. This will eliminate the possibility of naming collisions.

In the case of the cache expiration plugin, only one database is needed. Instead of creating multiple databases, we can create a single database with a single object store and use the cache name as an indexed property in the object store. We take this same approach with tag names in workbox-background-sync.

@jeffposnick
Copy link
Contributor

We now have a way of automatically completely deleting the IndexedDB storage along with cached entries as part of a "delete everything" method in workbox-cache-expiration:

/**
* Removes the underlying IndexedDB object store entirely.
*/
async delete() {
await this._db.deleteDatabase();
this._db = null;
}
}

I believe that that deletion operates on the object store level, rather than the database level, so maybe your suggestion still stands. But we should obviously make sure that we don't accidentally introduce a change that causes workbox-precaching data to be deleted when the "delete everything" method is invoked in workbox-cache-expiration.

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

No branches or pull requests

2 participants