---
title: "CDN configuration"
description: "Configure Edge CDN deployments with presets for static sites, e-commerce, media and APIs, plus JSON caching rules, path patterns and image optimisation."
url: "https://edge.network/docs/cdn/configuration"
section: "CDN"
---

# CDN configuration

Fine-tune your CDN behaviour with presets, caching rules and image optimisation settings.

## Configuration presets

Start with a preset optimised for your use case, then customise as needed.

- **Static Website:** long cache times for assets, short for HTML. Perfect for blogs, marketing sites and documentation.
- **E-commerce:** optimised for product catalogues with frequent updates. Caches images aggressively, bypasses cart/checkout.
- **Media & Streaming:** large file handling with long TTLs. Ideal for video platforms, podcasts and file downloads.
- **API Gateway:** minimal caching with origin pass-through. Good for APIs that need the CDN's global network without caching.
- **Custom:** full control with JSON configuration. Define your own caching rules and image optimisation settings.

![Configuration options when creating a deployment](/media/docs/control-cdn-create.svg)

## Custom configuration

For advanced use cases, you can define custom rules using JSON. Switch to **Advanced (JSON)** mode in the **Configuration** tab.

```json
{
  "caching": {
    "defaultTtl": 86400,
    "respectOriginHeaders": true,
    "rules": [
      { "path": "/static/**", "ttl": 31536000 },
      { "path": "/api/**", "bypassCache": true },
      { "path": "/assets/*.css", "ttl": 604800 }
    ]
  },
  "imageOptimization": {
    "enabled": true,
    "defaultQuality": 85,
    "defaultFormat": "auto",
    "rules": [
      { "path": "/thumbnails/**", "quality": 70, "maxWidth": 400 },
      { "path": "/hero/**", "quality": 90, "format": "avif" }
    ]
  }
}
```

## Caching rules

Define path-based rules to control how different content is cached.

| Property | Type | Description |
|---|---|---|
| `path` | string | Path pattern to match (supports `*` and `**` wildcards) |
| `ttl` | number | Cache duration in seconds |
| `bypassCache` | boolean | Skip caching entirely for matched paths |
| `ignoreQueryString` | boolean | Cache without considering query parameters |

> [!NOTE]
> Rules are evaluated in order. The first matching rule wins. If no rules match, the default TTL is used.

## Path patterns

Use glob-style patterns to match paths:

- `*`: matches any characters except `/`
- `**`: matches any characters including `/`

```text
# Match all files in /static/ and subdirectories
/static/**

# Match only .jpg files in /images/
/images/*.jpg

# Match a specific path
/assets/logo.png

# Match all API routes
/api/**
```

## Image optimisation settings

Configure default image optimisation behaviour and path-specific rules.

| Property | Type | Description |
|---|---|---|
| `enabled` | boolean | Enable/disable image optimisation entirely |
| `defaultQuality` | number (1–100) | Default compression quality for images |
| `defaultFormat` | string | Default output format: `auto`, `webp`, `avif`, `jpeg`, `png` |

> [!TIP]
> **Auto format.** Set `defaultFormat` to `auto` to automatically serve the best format based on browser support. The CDN checks the browser's `Accept` header and serves AVIF → WebP → JPEG in order of preference.

> [!WARNING]
> **Cache purge required.** Changing `defaultQuality` or `defaultFormat` only affects newly cached images. Existing cached images continue to use the old settings until they expire or you [purge the cache](/docs/cdn/purging).

## Image optimisation rules

Override image optimisation settings for specific paths:

| Property | Type | Description |
|---|---|---|
| `path` | string | Path pattern to match |
| `quality` | number | Override compression quality |
| `format` | string | Override output format |
| `maxWidth` | number | Maximum width in pixels |

## Simple vs advanced mode

### Simple mode

Use form controls to set basic options:

- Default cache TTL
- Enable/disable image optimisation
- Default quality and format

### Advanced mode

Full JSON configuration for:

- Path-based caching rules
- Cache bypass for specific paths
- Per-path image optimisation rules

## Next steps

- [Caching](/docs/cdn/caching) — Understand cache behaviour in depth
- [Image optimisation](/docs/cdn/image-optimization) — URL parameters for on-the-fly transforms
