@types/http-cache-semantics
Advanced tools
| export = CachePolicy; | ||
| declare class CachePolicy { | ||
| constructor(req: CachePolicy.Request, res: CachePolicy.Response, options?: CachePolicy.Options); | ||
| constructor(req: CachePolicy.HttpRequest, res: CachePolicy.HttpResponse, options?: CachePolicy.Options); | ||
@@ -23,5 +23,26 @@ /** | ||
| */ | ||
| satisfiesWithoutRevalidation(newRequest: CachePolicy.Request): boolean; | ||
| satisfiesWithoutRevalidation(newRequest: CachePolicy.HttpRequest): boolean; | ||
| /** | ||
| * Checks if the given request matches this cache entry, and how the cache can be used to satisfy it. Returns an object with: | ||
| * | ||
| * ``` | ||
| * { | ||
| * // If defined, you must send a request to the server. | ||
| * revalidation: { | ||
| * headers: {}, // HTTP headers to use when sending the revalidation response | ||
| * // If true, you MUST wait for a response from the server before using the cache | ||
| * // If false, this is stale-while-revalidate. The cache is stale, but you can use it while you update it asynchronously. | ||
| * synchronous: bool, | ||
| * }, | ||
| * // If defined, you can use this cached response. | ||
| * response: { | ||
| * headers: {}, // Updated cached HTTP headers you must use when responding to the client | ||
| * }, | ||
| * } | ||
| * ``` | ||
| */ | ||
| evaluateRequest(newRequest: CachePolicy.HttpRequest): CachePolicy.EvaluateRequestResult; | ||
| /** | ||
| * Returns updated, filtered set of response headers to return to clients receiving the cached response. | ||
@@ -37,2 +58,24 @@ * This function is necessary, because proxies MUST always remove hop-by-hop headers (such as `TE` and `Connection`) | ||
| /** | ||
| * Returns the Date header value from the response or the current time if invalid. | ||
| */ | ||
| date(): number; | ||
| /** | ||
| * Value of the Age header, in seconds, updated for the current time. | ||
| * May be fractional. | ||
| */ | ||
| age(): number; | ||
| /** | ||
| * Possibly outdated value of applicable max-age (or heuristic equivalent) in seconds. | ||
| * This counts since response's `Date`. | ||
| * | ||
| * For an up-to-date value, see `timeToLive()`. | ||
| * | ||
| * Returns the maximum age (freshness lifetime) of the response in seconds. | ||
| * @returns {number} The max-age value in seconds. | ||
| */ | ||
| maxAge(): number; | ||
| /** | ||
| * Returns approximate time in milliseconds until the response becomes stale (i.e. not fresh). | ||
@@ -47,6 +90,6 @@ * | ||
| /** | ||
| * Chances are you'll want to store the `CachePolicy` object along with the cached response. | ||
| * `obj = policy.toObject()` gives a plain JSON-serializable object. | ||
| * If true, this cache entry is past its expiration date. | ||
| * Note that stale cache may be useful sometimes, see `evaluateRequest()`. | ||
| */ | ||
| toObject(): CachePolicy.CachePolicyObject; | ||
| stale(): boolean; | ||
@@ -59,2 +102,8 @@ /** | ||
| /** | ||
| * Chances are you'll want to store the `CachePolicy` object along with the cached response. | ||
| * `obj = policy.toObject()` gives a plain JSON-serializable object. | ||
| */ | ||
| toObject(): CachePolicy.CachePolicyObject; | ||
| /** | ||
| * Returns updated, filtered set of request headers to send to the origin server to check if the cached | ||
@@ -69,10 +118,14 @@ * response can be reused. These headers allow the origin server to return status 304 indicating the | ||
| */ | ||
| revalidationHeaders(newRequest: CachePolicy.Request): CachePolicy.Headers; | ||
| revalidationHeaders(newRequest: CachePolicy.HttpRequest): CachePolicy.Headers; | ||
| /** | ||
| * Use this method to update the cache after receiving a new response from the origin server. | ||
| * Creates new CachePolicy with information combined from the previews response, | ||
| * and the new revalidation response. | ||
| * | ||
| * Returns {policy, modified} where modified is a boolean indicating | ||
| * whether the response body has been modified, and old cached body can't be used. | ||
| */ | ||
| revalidatedPolicy( | ||
| revalidationRequest: CachePolicy.Request, | ||
| revalidationResponse: CachePolicy.Response, | ||
| revalidationRequest: CachePolicy.HttpRequest, | ||
| revalidationResponse?: CachePolicy.HttpResponse, | ||
| ): CachePolicy.RevalidationPolicy; | ||
@@ -82,3 +135,3 @@ } | ||
| declare namespace CachePolicy { | ||
| interface Request { | ||
| interface HttpRequest { | ||
| url?: string | undefined; | ||
@@ -89,3 +142,5 @@ method?: string | undefined; | ||
| interface Response { | ||
| type Request = HttpRequest; | ||
| interface HttpResponse { | ||
| status?: number | undefined; | ||
@@ -95,2 +150,4 @@ headers: Headers; | ||
| type Response = HttpResponse; | ||
| interface Options { | ||
@@ -173,2 +230,31 @@ /** | ||
| } | ||
| interface EvaluateRequestRevalidation { | ||
| synchronous: boolean; | ||
| headers: CachePolicy.Headers; | ||
| } | ||
| interface EvaluateRequestHitWithoutRevalidationResult { | ||
| response: { | ||
| headers: CachePolicy.Headers; | ||
| }; | ||
| revalidation: undefined; | ||
| } | ||
| interface EvaluateRequestHitWithRevalidationResult { | ||
| response: { | ||
| headers: CachePolicy.Headers; | ||
| }; | ||
| revalidation: EvaluateRequestRevalidation; | ||
| } | ||
| interface EvaluateRequestMissResult { | ||
| response: undefined; | ||
| revalidation: EvaluateRequestRevalidation; | ||
| } | ||
| type EvaluateRequestResult = | ||
| | EvaluateRequestHitWithRevalidationResult | ||
| | EvaluateRequestHitWithoutRevalidationResult | ||
| | EvaluateRequestMissResult; | ||
| } |
| { | ||
| "name": "@types/http-cache-semantics", | ||
| "version": "4.0.4", | ||
| "version": "4.2.0", | ||
| "description": "TypeScript definitions for http-cache-semantics", | ||
@@ -23,4 +23,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-cache-semantics", | ||
| "dependencies": {}, | ||
| "typesPublisherContentHash": "6cf8e230d4a5ae72d31765a8facf404307c59791befc65343d177843c7bbae91", | ||
| "typeScriptVersion": "4.5" | ||
| "peerDependencies": {}, | ||
| "typesPublisherContentHash": "f5ae2b8a76a826965b8617b73b86a92dc7b5dd7230a0d6d8e1ecb6139ec75db8", | ||
| "typeScriptVersion": "5.2" | ||
| } |
@@ -11,3 +11,3 @@ # Installation | ||
| ### Additional Details | ||
| * Last updated: Tue, 07 Nov 2023 03:09:37 GMT | ||
| * Last updated: Tue, 27 Jan 2026 09:06:16 GMT | ||
| * Dependencies: none | ||
@@ -14,0 +14,0 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
12149
30.94%224
49.33%4
100%