Comunica
    Preparing search index...

    Class CachePolicyHttpCacheSemanticsWrapper

    Wrapper over the cache policy of http-cache-semantics to expose it as an ICachePolicy.

    Implements

    Index

    Constructors

    Methods

    • Returns updated, filtered set of response headers to return to clients receiving the cached response. This function is necessary, because proxies MUST always remove hop-by-hop headers (such as TE and Connection) and update response's Age to avoid doubling cache time. Example: cachedResponse.headers = cachePolicy.responseHeaders(cachedResponse);

      Returns Headers

    • Returns updated, filtered set of request headers to send to the origin server to check if the cached response can be reused. These headers allow the origin server to return status 304 indicating the response is still fresh. All headers unrelated to caching are passed through as-is.

      Use this method when updating cache from the origin server.

      Parameters

      Returns Promise<Headers>

      updateRequest.headers = cachePolicy.revalidationHeaders(updateRequest);
      
    • This is the most important method. Use this method to check whether a cached response is still fresh in the context of the new request.

      If it returns true, then the given request matches the original response this cache policy has been created with, and the response can be reused without contacting the server. Note that the old response can't be returned without being updated, see responseHeaders().

      If it returns false, then the response may not be matching at all (e.g. it's for a different URL or method), or may require to be refreshed first (see revalidationHeaders()).

      Parameters

      Returns Promise<boolean>

    • Returns approximate time in milliseconds until the response becomes stale (i.e. not fresh).

      After that time (when timeToLive() <= 0) the response might not be usable without revalidation. However, there are exceptions, e.g. a client can explicitly allow stale responses, so always check with satisfiesWithoutRevalidation().

      Returns number