---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# SimpleCache.get

▸ **get**(): `string`

Gets the entry associated with the key `key` from the cache.

## Syntax

```js
get(key)
```

### Parameters

- `key` _: string_
  - The key to retrieve from within the cache.

### Return value

If the key does not exist in the cache, this returns `null`.

If the key does exist in the cache, this returns a `SimpleCacheEntry`.

### Exceptions

- `TypeError`
  - If the provided `key`:
    - Is an empty string
    - Cannot be coerced to a string
    - Is longer than 8135 characters

## Examples

In this example we attempt to retrieve an entry from the Fastly Cache, and return a message stating whether the entry was in the Fastly Cache or not.

```js
/// <reference types="@fastly/js-compute" />

import { SimpleCache } from 'fastly:cache';

addEventListener('fetch', event => event.respondWith(app(event)));

async function app(event) {
  const path = new URL(event.request.url).pathname;
  let page = SimpleCache.get(path);
  return new Response(page ? `${path} is in the cache` : `${path} is not in the cache`, {
    headers: {
      'content-type': 'text/plain;charset=UTF-8'
    }
  });
}
```
