Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serwist/expiration

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serwist/expiration - npm Package Compare versions

Comparing version 9.0.0-preview.12 to 9.0.0-preview.13

25

dist/CacheExpiration.d.ts

@@ -18,7 +18,6 @@ interface CacheExpirationConfig {

/**
* The `CacheExpiration` class allows you define an expiration and / or
* limit on the number of responses stored in a
* [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
* Allows you to expires cached responses based on age or maximum number of entries.
* @see https://serwist.pages.dev/docs/expiration/cache-expiration
*/
declare class CacheExpiration {
export declare class CacheExpiration {
private _isRunning;

@@ -44,5 +43,4 @@ private _rerunRequested;

/**
* 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.
* Updates the timestamp for the given URL, allowing it to be correctly
* tracked by the class.
*

@@ -53,8 +51,8 @@ * @param url

/**
* Can be used to check if a URL has expired or not before it's used.
* Checks if a URL has expired or not before it's used.
*
* This requires a look up from IndexedDB, so can be slow.
* This looks the timestamp up in IndexedDB and can be slow.
*
* Note: This method will not remove the cached entry, call
* `expireEntries()` to remove indexedDB and Cache entries.
* Note: This method does not remove an expired entry, call
* `expireEntries()` to remove such entries instead.
*

@@ -66,8 +64,7 @@ * @param url

/**
* Removes the IndexedDB object store used to keep track of cache expiration
* metadata.
* Removes the IndexedDB used to keep track of cache expiration metadata.
*/
delete(): Promise<void>;
}
export { CacheExpiration };
export {};
//# sourceMappingURL=CacheExpiration.d.ts.map

@@ -18,3 +18,3 @@ import type { SerwistPlugin } from "@serwist/core";

/**
* Whether to opt this cache in to automatic deletion if the available storage quota has been exceeded.
* Whether to opt this cache into automatic deletion if the available storage quota has been exceeded.
*/

@@ -25,8 +25,7 @@ purgeOnQuotaError?: boolean;

* This plugin can be used in a `@serwist/strategies` Strategy to regularly enforce a
* limit on the age and / or the number of cached requests.
* limit on the age and/or the number of cached requests.
*
* It can only be used with Strategy instances that have a
* [custom `cacheName` property set](/web/tools/workbox/guides/configure-workbox#custom_cache_names_in_strategies).
* In other words, it can't be used to expire entries in strategy that uses the
* default runtime cache name.
* It can only be used with Strategy instances that have a custom `cacheName` property set.
* In other words, it can't be used to expire entries in strategies that use the default runtime
* cache name.
*

@@ -38,10 +37,11 @@ * Whenever a cached response is used or updated, this plugin will look

* because the expiration clean up will not have occurred until *after* the
* cached response has been used. If the response has a "Date" header, then
* a light weight expiration check is performed and the response will not be
* used immediately.
* cached response has been used. If the response has a "Date" header, then a lightweight expiration
* check is performed, and the response will not be used immediately.
*
* When using `maxEntries`, the entry least-recently requested will be removed
* from the cache first.
* When using `maxEntries`, the least recently requested entry will be removed
* from the cache.
*
* @see https://serwist.pages.dev/docs/expiration/expiration-plugin
*/
declare class ExpirationPlugin implements SerwistPlugin {
export declare class ExpirationPlugin implements SerwistPlugin {
private readonly _config;

@@ -101,12 +101,8 @@ private readonly _maxAgeSeconds?;

/**
* This is a helper method that performs two operations:
* Deletes the underlying `Cache` instance associated with this instance and the metadata
* from IndexedDB used to keep track of expiration details for each `Cache` instance.
*
* - Deletes *all* the underlying Cache instances associated with this plugin
* instance, by calling caches.delete() on your behalf.
* - Deletes the metadata from IndexedDB used to keep track of expiration
* details for each Cache instance.
*
* When using cache expiration, calling this method is preferable to calling
* `caches.delete()` directly, since this will ensure that the IndexedDB
* metadata is also cleanly removed and open IndexedDB instances are deleted.
* metadata is also cleanly removed and that open IndexedDB instances are deleted.
*

@@ -119,3 +115,2 @@ * Note that if you're *not* using cache expiration for a given cache, calling

}
export { ExpirationPlugin };
//# sourceMappingURL=ExpirationPlugin.d.ts.map
{
"name": "@serwist/expiration",
"version": "9.0.0-preview.12",
"version": "9.0.0-preview.13",
"type": "module",

@@ -33,8 +33,8 @@ "description": "A module that expires cached responses based on age or maximum number of entries.",

"idb": "8.0.0",
"@serwist/core": "9.0.0-preview.12"
"@serwist/core": "9.0.0-preview.13"
},
"devDependencies": {
"rollup": "4.9.6",
"typescript": "5.4.0-dev.20240206",
"@serwist/constants": "9.0.0-preview.12"
"rollup": "4.12.0",
"typescript": "5.5.0-dev.20240304",
"@serwist/constants": "9.0.0-preview.13"
},

@@ -41,0 +41,0 @@ "peerDependencies": {

@@ -31,7 +31,6 @@ /*

/**
* The `CacheExpiration` class allows you define an expiration and / or
* limit on the number of responses stored in a
* [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
* Allows you to expires cached responses based on age or maximum number of entries.
* @see https://serwist.pages.dev/docs/expiration/cache-expiration
*/
class CacheExpiration {
export class CacheExpiration {
private _isRunning = false;

@@ -141,5 +140,4 @@ private _rerunRequested = false;

/**
* 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.
* Updates the timestamp for the given URL, allowing it to be correctly
* tracked by the class.
*

@@ -162,8 +160,8 @@ * @param url

/**
* Can be used to check if a URL has expired or not before it's used.
* Checks if a URL has expired or not before it's used.
*
* This requires a look up from IndexedDB, so can be slow.
* This looks the timestamp up in IndexedDB and can be slow.
*
* Note: This method will not remove the cached entry, call
* `expireEntries()` to remove indexedDB and Cache entries.
* Note: This method does not remove an expired entry, call
* `expireEntries()` to remove such entries instead.
*

@@ -189,4 +187,3 @@ * @param url

/**
* Removes the IndexedDB object store used to keep track of cache expiration
* metadata.
* Removes the IndexedDB used to keep track of cache expiration metadata.
*/

@@ -200,3 +197,1 @@ async delete(): Promise<void> {

}
export { CacheExpiration };

@@ -31,3 +31,3 @@ /*

/**
* Whether to opt this cache in to automatic deletion if the available storage quota has been exceeded.
* Whether to opt this cache into automatic deletion if the available storage quota has been exceeded.
*/

@@ -39,8 +39,7 @@ purgeOnQuotaError?: boolean;

* This plugin can be used in a `@serwist/strategies` Strategy to regularly enforce a
* limit on the age and / or the number of cached requests.
* limit on the age and/or the number of cached requests.
*
* It can only be used with Strategy instances that have a
* [custom `cacheName` property set](/web/tools/workbox/guides/configure-workbox#custom_cache_names_in_strategies).
* In other words, it can't be used to expire entries in strategy that uses the
* default runtime cache name.
* It can only be used with Strategy instances that have a custom `cacheName` property set.
* In other words, it can't be used to expire entries in strategies that use the default runtime
* cache name.
*

@@ -52,10 +51,11 @@ * Whenever a cached response is used or updated, this plugin will look

* because the expiration clean up will not have occurred until *after* the
* cached response has been used. If the response has a "Date" header, then
* a light weight expiration check is performed and the response will not be
* used immediately.
* cached response has been used. If the response has a "Date" header, then a lightweight expiration
* check is performed, and the response will not be used immediately.
*
* When using `maxEntries`, the entry least-recently requested will be removed
* from the cache first.
* When using `maxEntries`, the least recently requested entry will be removed
* from the cache.
*
* @see https://serwist.pages.dev/docs/expiration/expiration-plugin
*/
class ExpirationPlugin implements SerwistPlugin {
export class ExpirationPlugin implements SerwistPlugin {
private readonly _config: ExpirationPluginOptions;

@@ -254,12 +254,8 @@ private readonly _maxAgeSeconds?: number;

/**
* This is a helper method that performs two operations:
* Deletes the underlying `Cache` instance associated with this instance and the metadata
* from IndexedDB used to keep track of expiration details for each `Cache` instance.
*
* - Deletes *all* the underlying Cache instances associated with this plugin
* instance, by calling caches.delete() on your behalf.
* - Deletes the metadata from IndexedDB used to keep track of expiration
* details for each Cache instance.
*
* When using cache expiration, calling this method is preferable to calling
* `caches.delete()` directly, since this will ensure that the IndexedDB
* metadata is also cleanly removed and open IndexedDB instances are deleted.
* metadata is also cleanly removed and that open IndexedDB instances are deleted.
*

@@ -282,3 +278,1 @@ * Note that if you're *not* using cache expiration for a given cache, calling

}
export { ExpirationPlugin };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc