---
title: Request
summary: The Request class as specified by WHATWG
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/interface.Request/
---

**Kind:** Interface  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1442

Extends `Body`.

The Request class as [specified by WHATWG](https://fetch.spec.whatwg.org/#ref-for-dom-request%E2%91%A0)

**Note**: Can only be used when processing requests, not during build-time initialization.

**See also**

- [Request on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Request)

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1520

```javascript
new Request(input: RequestInfo | URL, init?: RequestInit)
```

**Parameters**

- `input`: `RequestInfo | URL`
- `init`: `RequestInit` (optional)

## Properties

### headers

**Type:** `Headers`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1450

Returns a Headers object consisting of the headers associated with request.

### method

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1456

Returns request's HTTP method, which is "GET" by default.

### url

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1468

Returns the URL of request as a string.

### backend

**Type:** `Backend | undefined`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1477

The backend this request was sent to, or `undefined` for the downstream
request itself.

### isCacheable

**Type:** `boolean | undefined`  
**Flags:** read-only, since 3.30.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1512

Fastly-specific property - determines whether a request is cacheable per conservative RFC 9111 semantics.
In particular, this function checks whether the request method is `GET` or `HEAD`, and
considers requests with other methods uncacheable. Applications where it is safe to cache
responses to other methods should consider using their own cacheability check instead of
this function.

This function always returns undefined on hosts not supporting the HTTP Cache API (i.e. Viceroy)

## Methods

### clone

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1471

```javascript
clone(): Request
```

Creates a copy of the current Request object.

**Returns**

`Request`

### setCacheKey

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1491

```javascript
setCacheKey(key: string): void
```

Set a custom cache key for this request.

**Parameters**

- `key`: `string` — The cache key to use.

**Returns**

`void`

### setCacheOverride

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1483

```javascript
setCacheOverride(override: CacheOverride): void
```

Set the cache override for this request.

**Parameters**

- `override`: `CacheOverride` — The cache override configuration to apply.

**Returns**

`void`

### setManualFramingHeaders

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1500

```javascript
setManualFramingHeaders(manual: boolean): void
```

Controls how framing headers (`Content-Length`, `Transfer-Encoding`) are
determined. In "manual" mode, any provided framing headers will be
honored. In "automatic" mode (the default), they are set based on the
body.

**Parameters**

- `manual`: `boolean` — Whether to use manual mode for framing headers.

**Returns**

`void`
