---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# setDefaultDynamicBackendConfig()

The **`setDefaultDynamicBackendConfig()`** allows setting backend configuration defaults that should apply to any newly created dynamic backends via the `new Backend()` constructor.

### Parameters

- `defaultDynamicBackendConfig`

  - : An Object which contains the generic configuration options to apply to newly created Backends.
    - `connectTimeout` _: number_ _**optional**_
      - Maximum duration in milliseconds to wait for a connection to this backend to be established.
      - If exceeded, the connection is aborted and a 503 response will be presented instead.
      - Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
    - `firstByteTimeout` _: number_ _**optional**_
      - Maximum duration in milliseconds to wait for the server response to begin after a TCP connection is established and the request has been sent.
      - If exceeded, the connection is aborted and a 503 response will be presented instead.
      - Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
    - `betweenBytesTimeout` _: number_ _**optional**_
      - Maximum duration in milliseconds that Fastly will wait while receiving no data on a download from a backend.
      - If exceeded, the response received so far will be considered complete and the fetch will end.
      - Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
    - `useSSL` _: boolean_ _**optional**_
      - Whether or not to require TLS for connections to this backend.
    - `dontPool` _: boolean_ _**optional**_
      - Determine whether or not connections to the same backend should be pooled across different sessions.
      - Fastly considers two backends “the same” if they're registered with the same name and the exact same settings.
      - In those cases, when pooling is enabled, if Session 1 opens a connection to this backend it will be left open, and can be re-used by Session 2.
      - This can help improve backend latency, by removing the need for the initial network / TLS handshake(s).
      - By default, pooling is enabled for dynamic backends.
    - `tlsMinVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
      - Minimum allowed TLS version on SSL connections to this backend.
      - If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
      - Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
    - `tlsMaxVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
      - Maximum allowed TLS version on SSL connections to this backend.
      - If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
      - Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
    - `certificateHostname` _: string_ _**optional**_
      - Define the hostname that the server certificate should declare.
      - Throws a [`TypeError`](../globals/TypeError/TypeError.mdx) if the value is an empty string.
    - `caCertificate` _: string_ _**optional**_
      - The CA certificate to use when checking the validity of the backend.
      - Throws a [`TypeError`](../globals/TypeError/TypeError.mdx) if the value is an empty string.
    - `ciphers` _: string_ _**optional**_
      - List of OpenSSL ciphers to support for connections to this origin.
      - If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
      - [List of ciphers supported by Fastly](https://developer.fastly.com/learning/concepts/routing-traffic-to-fastly/#use-a-tls-configuration).
      - Throws a [`TypeError`](../globals/TypeError/TypeError.mdx) if the value is an empty string.
    - `clientCertificate` _: object_ _**optional**_
      - The client certificate to provide for the TLS handshake
      - `certificate` _: string_
        - The PEM certificate string.
      - `key` _: SecretStoreEntry_
        - The `SecretStoreEntry` to use for the key, created via [`SecretStore.prototype.get`](pathname://../fastly:secret-store/SecretStore/prototype/get.mdx) or alteratively via [`SecretStore.fromBytes`](pathname://../fastly:secret-store/SecretStore/fromBytes.mdx).
    - `httpKeepalive` _: number_ _**optional**_
      - Enable HTTP keepalive, setting the timout in milliseconds.
    - `tcpKeepalive` _: boolean | object_ _**optional**_
      - Enable TCP keepalive. When an object, optionally setting the keepalive configuration options.
      - `timeSecs` _: number_ _**optional**_
        - Configure how long to wait after the last sent data over the TCP connection before starting to send TCP keepalive probes.
      - `intervalSecs` _: number_ _**optional**_
        - Configure how long to wait between each TCP keepalive probe sent to the backend to determine if it is still active.
      - `probes` _: number_ _**optional**_
        - Number of probes to send to the backend before it is considered dead.

## Syntax

```js
setDefaultDynamicBackendConfig(defaultConfig);
```

### Return value

None.

## Examples

In this example an explicit Dynamic Backend is created and supplied to the fetch request, with timeouts and TLS options provided from the default backend configuration options.

<Fiddle config={{
  "type": "javascript",
  "title": "Explicit Dynamic Backend Example",
  "origins": [
    "https://http-me.fastly.dev"
  ],
  "src": {
    "deps": "{\n  \"@fastly/js-compute\": \"^1.0.1\"\n}",
    "main": `
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
import { Backend, setDefaultDynamicBackendConfig } from "fastly:backend";
allowDynamicBackends(true);
setDefaultDynamicBackendConfig({
  connectTimeout: 1000,
  firstByteTimeout: 15_000,
  betweenBytesTimeout: 10_000,
  useSSL: true,
  sslMinVersion: 1.3,
  sslMaxVersion: 1.3
});
async function app() {
  // For any request, return the fastly homepage -- without defining a backend!
  // Timeouts and TLS configuration still get set from the default backend configuration above.
  const backend = new Backend({
    name: 'fastly',
    target: 'fastly.com',
    hostOverride: "www.fastly.com"
  });
  return fetch('https://www.fastly.com/', {
    backend // Here we are configuring this request to use the backend from above.
  });
}
addEventListener("fetch", event => event.respondWith(app(event)));
`
  },
  "requests": [
    {
      "enableCluster": true,
      "enableShield": false,
      "enableWAF": false,
      "method": "GET",
      "path": "/status=200",
      "useFreshCache": false,
      "followRedirects": false,
      "tests": "",
      "delay": 0
    }
  ],
  "srcVersion": 1
}}>

```js
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from 'fastly:experimental';
import { Backend } from 'fastly:backend';
allowDynamicBackends(true);
setDefaultDynamicBackendConfig({
  connectTimeout: 1000,
  firstByteTimeout: 15_000,
  betweenBytesTimeout: 10_000,
  useSSL: true,
  sslMinVersion: 1.3,
  sslMaxVersion: 1.3,
});
async function app() {
  // For any request, return the fastly homepage -- without defining a backend!
  const backend = new Backend({
    name: 'fastly',
    target: 'fastly.com',
    hostOverride: 'www.fastly.com',
  });
  return fetch('https://www.fastly.com/', {
    backend, // Here we are configuring this request to use the backend from above.
  });
}
addEventListener('fetch', (event) => event.respondWith(app(event)));
```

</Fiddle>
