Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# CacheStorage

This CDP domain is experimental.

- Types

- Commands

- Events

## Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class CacheId

  Unique identifier of the Cache object.

class CachedResponseType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

  type of HTTP response cached

  BASIC = 'basic'
  CORS = 'cors'
  DEFAULT = 'default'
  ERROR = 'error'
  OPAQUE_RESPONSE = 'opaqueResponse'
  OPAQUE_REDIRECT = 'opaqueRedirect'

class DataEntry(request_url, request_method, request_headers, response_time, response_status, response_status_text, response_type, response_headers)

  Data entry.

  request_url: `str`

    Request URL.

  request_method: `str`

    Request method.

  request_headers: `List`[`Header`]

    Request headers

  response_time: `float`

    Number of seconds since epoch.

  response_status: `int`

    HTTP response status code.

  response_status_text: `str`

    HTTP response status text.

  response_type: `CachedResponseType`

    HTTP response type

  response_headers: `List`[`Header`]

    Response headers

class Cache(cache_id, security_origin, storage_key, cache_name, storage_bucket=None)

  Cache identifier.

  cache_id: `CacheId`

    An opaque unique id of the cache.

  security_origin: `str`

    Security origin of the cache.

  storage_key: `str`

    Storage key of the cache.

  cache_name: `str`

    The name of the cache.

  storage_bucket: `Optional`[`StorageBucket`] = None

    Storage bucket of the cache.

class Header(name, value)
  name: `str`
  value: `str`

class CachedResponse(body)

  Cached response

  body: `str`

    Entry content, base64-encoded. (Encoded as a base64 string when passed over JSON)

## Commands

Each command is a generator function. The return type `Generator[x, y, z]` indicates that the generator yields arguments of type `x`, it must be resumed with an argument of type `y`, and it returns type `z`. In this library, types `x` and `y` are the same for all commands, and `z` is the return type you should pay attention to. For more information, see Getting Started: Commands.

delete_cache(cache_id)

  Deletes a cache.

  Parameters:

    cache_id (`CacheId`) – Id of cache for deletion.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

delete_entry(cache_id, request)

  Deletes a cache entry.

  Parameters:

    - cache_id (`CacheId`) – Id of cache where the entry will be deleted.

    - request (`str`) – URL spec of the request.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

request_cache_names(security_origin=None, storage_key=None, storage_bucket=None)

  Requests cache names.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `List`[`Cache`]]

  Returns:

    Caches for the security origin.

request_cached_response(cache_id, request_url, request_headers)

  Fetches cache entry.

  Parameters:

    - cache_id (`CacheId`) – Id of cache that contains the entry.

    - request_url (`str`) – URL spec of the request.

    - request_headers (`List`[`Header`]) – headers of the request.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `CachedResponse`]

  Returns:

    Response read from the cache.

request_entries(cache_id, skip_count=None, page_size=None, path_filter=None)

  Requests data from cache.

  Parameters:

    - cache_id (`CacheId`) – ID of cache to get entries from.

    - skip_count (`Optional`[`int`]) – (Optional) Number of records to skip.

    - page_size (`Optional`[`int`]) – (Optional) Number of records to fetch.

    - path_filter (`Optional`[`str`]) – (Optional) If present, only return the entries containing this substring in the path

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `Tuple`[`List`[`DataEntry`], `float`]]

  Returns:

    A tuple with the following items:

    0. cacheDataEntries - Array of object store data entries.

    1. returnCount - Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.

## Events

There are no events in this module.