workbox-expiration. CacheExpiration
The CacheExpiration
class allows you define an expiration and / or
limit on the number of responses stored in a
Cache
.
Constructor
CacheExpiration
new CacheExpiration(cacheName, config)
To construct a new CacheExpiration instance you must provide at least
one of the config
properties.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
cacheName |
string Name of the cache to apply restrictions to. |
||||||||
config |
Object Values in
|
Methods
delete
delete()
Removes the IndexedDB object store used to keep track of cache expiration metadata.
expireEntries
expireEntries()
Expires entries for the given cache and given criteria.
isURLExpired
isURLExpired(url) returns boolean
Can be used to check if a URL has expired or not before it's used.
This requires a look up from IndexedDB, so can be slow.
Note: This method will not remove the cached entry, call
expireEntries()
to remove indexedDB and Cache entries.
Parameter |
|
---|---|
url |
string |
- Returns
-
boolean
updateTimestamp
updateTimestamp(url)
Update the timestamp for the given URL. This ensures the when removing entries based on maximum entries, most recently used is accurate or when expiring, the timestamp is up-to-date.
Parameter |
|
---|---|
url |
string |