> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fivemesh.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up FiveMesh Cache

> Enable resource download caching for a registered FiveM server and copy the generated server.cfg block.

FiveMesh Cache is a resource download proxy for FiveM servers.

Players download resources through a FiveMesh cache URL. Cache hits are served from FiveMesh. Cache misses are fetched from your origin once, then reused until you purge or refresh the cache version.

## Prerequisites

Before you enable Cache, confirm:

* The active workspace has trial or subscription access.
* The cfx.re server is registered in **Account** > **Servers**.
* You can edit your server's `server.cfg`.
* You or your host can edit firewall and DDoS protection rules for the origin machine.
* Your organization role can create Cache configuration if you are in an organization workspace.

<Warning>
  Servers that use a direct-IP connection endpoint should use a domain or
  subdomain before Cache is enabled. Enabling Cache on a direct-IP endpoint can
  cause player connection errors. Point a domain or subdomain at the server IP,
  then use that hostname for Cache services. If you do not have one, open a
  [Discord ticket](https://discord.gg/wBJamWETxr) to request a free FiveMesh
  subdomain.
</Warning>

## Enable Cache

<Steps>
  <Step title="Open Cache">
    In the dashboard sidebar, open **Cache**.
  </Step>

  <Step title="Choose a registered server">
    In the **Servers** tab, find the registered server you want to cache.
  </Step>

  <Step title="Enable Cache">
    Click **Enable Cache**.
  </Step>

  <Step title="Copy the setup block">
    Copy the generated `server.cfg` block immediately.

    The block includes a `fileserver_add` line and an `adhesive_cdnKey` secret.
  </Step>

  <Step title="Update server.cfg">
    Paste the block into your server configuration and restart or reload your server according to your normal deployment process.
  </Step>
</Steps>

Example shape:

```cfg theme={null}
fileserver_add ".*" "https://cache.fivemesh.io/YOUR_SERVER_ID/files"
adhesive_cdnKey "YOUR_SECRET_KEY"
```

<Warning>
  The adhesive key is only shown when it is created or rotated. If you lose it, rotate the key from Cache settings and update `server.cfg`.
</Warning>

## Origin URL

FiveMesh detects an origin for the registered cfx.re server. In most cases, keep the detected origin.

Change the origin URL only when the detected address is not the address Cache should use for resource downloads.

## Allow FiveMesh to reach your origin

FiveMesh fetches cache misses from your origin through Cloudflare's network.

Game host firewalls and DDoS protection often filter data center traffic while allowing player traffic. If the origin machine or your host protects the fileserver port, allow Cloudflare's published IP ranges on that TCP port before you enable Cache. The current ranges are listed at [cloudflare.com/ips](https://www.cloudflare.com/ips/).

<Info>
  If the machine runs several FiveM servers, apply the same rule to every
  fileserver port. Protection rules that cover only one port cause download
  errors for the other servers.
</Info>

If downloads fail after Cache is enabled while the server runs normally, see [players get download errors while the server runs fine](/reference/troubleshooting#players-get-download-errors-while-the-server-runs-fine).

## Next steps

* Manage purge, origin and key rotation from [Cache operations](/cache/operations).
* Review [troubleshooting](/reference/troubleshooting) if players cannot connect after Cache is enabled.
* Register missing servers from [Account servers](/account/servers).
