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
- A second machine or VM with a public address, with Docker installed.
- Your game server's address and port, reachable from that machine.
- Access to the server console to run
fileserver_add.
Set up the proxy
- Create a folder on the proxy machine with three items: a file named
default.template, a file namedDockerfile, and an empty folder namedcache.
- 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;
}
}
- 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;'"
- Build the image and start the container. The
REMOTEvalue 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
- 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.
- 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.
- Restart the server and check that the setting still applies. The cookbook does not say whether
fileserver_addis kept after a restart, and the server commands page does not list it.
Check that it works
- Join the server with a test account.
- Run
docker logs fxproxyon the proxy machine. - Look at the last field of each log line,
$upstream_cache_status. The first download of a file should showMISS. A later download of the same file should showHIT.
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:
- Stop the container:
docker stop fxproxy - Delete the files inside the
cachefolder. - 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
REMOTEpoints to your game server and that the proxy machine can reach it. - You restrict the file server by IP: the server settings
sv_httpFileServerProxyOnly(defaultfalse) andsv_proxyIPRangesaffect 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
- Optimizing Resource Downloads Using a Caching Proxy (Cfx.re docs cookbook)
- Server commands (FiveM server manual)
- Discussion thread, read only from search results: Optimizing resource downloads using a caching proxy (forum.cfx.re)
Last checked: 2026-12-05
FiveM.tools was founded with sponsorship from Nyru.