Guide

Slow FiveM Resource Downloads: Set Up a Caching Proxy

Speed up FiveM resource downloads with a caching proxy. Covers fileserver_add, the nginx and Docker setup, and clearing the cache after updates.

Players wait a long time on the loading screen because every resource file comes from your game server. A caching proxy stores those files after the first download, so the next players get them from the proxy. This guide shows the setup from the official Cfx.re cookbook article.

Short answer

Run an nginx caching proxy in Docker on a second machine. Point the server at it with fileserver_add. After each change to a resource, clear the proxy cache, because the proxy does not check file hashes.

Why downloads are slow

When a player joins, the FiveM client asks the server for every resource file it needs. By default the game server sends those files itself. If many players join at once, the server's upload bandwidth becomes the limit. The cookbook describes moving that work to a proxy that keeps copies of the files.

What you need

  1. A second machine or VM with a public address, with Docker installed.
  2. Your game server's address and port, reachable from that machine.
  3. Access to the server console to run fileserver_add.

Set up the proxy

  1. Create a folder on the proxy machine with three items: a file named default.template, a file named Dockerfile, and an empty folder named cache.
  1. Put this in default.template:
proxy_cache_path /srv/cache levels=1:2 keys_zone=assets:48m max_size=10g ;
log_format asset '$remote_addr - [$time_local] "$request" $status $body_bytes_sent $upstream_cache_status';

server {
        listen 80;

        location /files/ {
                access_log /dev/stdout asset;
                add_header X-Cache-Status $upstream_cache_status;
                proxy_cache_lock on;
                proxy_pass $REMOTE$request_uri;
                proxy_cache assets;
                proxy_cache_valid 1y;
                proxy_cache_key $request_uri$is_args$args;
        }
}
  1. Put this in Dockerfile:
FROM nginx:alpine
COPY default.template /etc/nginx/conf.d/default.template
CMD sh -c "envsubst \"`env | awk -F = '{printf \" \\\\$%s\", $1}'`\" < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
  1. Build the image and start the container. The REMOTE value is an example from the cookbook. Replace it with your game server's address and port:
docker build -t fxproxy .
docker run -d --name=fxproxy -e REMOTE=http://10.10.0.2:30120 -p 80:80 -v $PWD/cache:/srv/cache fxproxy

The cookbook says this config should sit behind another proxy that provides HTTP/2 over TLS. It does not give a full TLS setup, so add that yourself if you expose the proxy publicly.

Tell the server to use the proxy

  1. Open the server console and run this, replacing the address with your proxy's address:
fileserver_add ".*" "http://YOUR_PROXY_ADDRESS/files"

The URL must not end with a slash. The pattern .* matches every resource.

  1. Set the key from the cookbook. It calls this command old but required, to avoid corrupted cache entries:
adhesive_cdnKey "someSecurePassphrase"

Use your own passphrase.

  1. Restart the server and check that the setting still applies. The cookbook does not say whether fileserver_add is kept after a restart, and the server commands page does not list it.

Check that it works

  1. Join the server with a test account.
  2. Run docker logs fxproxy on the proxy machine.
  3. Look at the last field of each log line, $upstream_cache_status. The first download of a file should show MISS. A later download of the same file should show HIT.

If the log shows no requests at all, the client is not reaching the proxy. Check the fileserver_add address and the port 80 rule in your firewall.

Clear the cache after updates

The cookbook says there is no hash-based cache invalidation. If you change or restart a resource, the proxy can keep serving the old file. Before you restart the server after a resource change:

  1. Stop the container: docker stop fxproxy
  2. Delete the files inside the cache folder.
  3. Start the container: docker start fxproxy

Do this every time a resource file changes.

If it does not work

  • Every line shows MISS: the requests go through the proxy, but the cache is not being reused. Check that the file path is the same on each request and that nothing clears the cache in between.
  • Players get old or broken files after an update: clear the cache as shown above.
  • The proxy returns errors: check that REMOTE points to your game server and that the proxy machine can reach it.
  • You restrict the file server by IP: the server settings sv_httpFileServerProxyOnly (default false) and sv_proxyIPRanges affect this. Check that your proxy address falls in the ranges you allow.

Frequently asked questions

Is this a CDN service?

No. You run the proxy yourself on a machine you control. The cookbook does not use a third-party CDN.

Does sv_forceIndirectListing speed up downloads?

No. The server commands page describes it as a setting that stops the server from being advertised with its real IP address. It is about the server listing, not resource files.

Does this help a small server?

The cookbook gives no player count where it becomes useful. Test it on your own server and compare join times before and after.

Is the cookbook up to date?

The article is from 2019 and says newer information may exist. The command names and the nginx config may have changed. Check the console output after fileserver_add before you rely on it.

Next step: if your server is slow for other reasons, read how to find what is lagging your FiveM server.

Sources

Last checked: 2026-12-05

FiveM.tools was founded with sponsorship from Nyru.