FiveM | How to make your FiveM server joins faster
If players sit on the loading screen for a long time when they join your server, the cause is almost always the resource download. The quickest fix is to serve those downloads from a CDN with FXCache, which takes a few minutes to set up and has a free plan. This guide explains why joins are slow, how to set up FXCache, and what else you can do to cut join times.
Why joins are slow
Before a player can spawn, their game downloads every resource your server has started that it doesn't already have. That includes scripts, streamed vehicles, maps, clothing and any files the resources list for their in-game menus.
Three things make this slow:
- Every file comes from your server. By default, the game server sends the files to each player itself.
- Everything shares one connection. All players downloading at once split your server's internet connection, and that same connection also carries the game traffic.
- Distance matters. The further a player is from your server, the slower a large download tends to be.
Players keep a local cache, so the first join is the slowest. After that they only download files that have changed. If you update a large resource, everyone has to download it again on their next join.
A CDN fixes all three. Files come from the CDN instead of your server, the downloads no longer share your game server's connection, and players download from a location close to them.
Speed up joins with FXCache
FXCache is a CDN built for FiveM and RedM resource downloads. It runs on Cloudflare's network, which covers more than 340 cities in more than 130 countries. Your server sends each file once, and after that every player downloads it from the city closest to them.
FXCache is made by the same company as Hyper Layer. It works with any host, so you don't need to host with us to use it.
Set up FXCache
-
Sign in to FXCache with Discord.
-
Add your server. If you are asked to verify that you own it, add the short verification line you are given to
server.cfg. -
Paste your two lines into
server.cfg. Your dashboard shows the exact values for your server:fileserver_add ".*" "https://edge.fxcache.net/<id>/files"set adhesive_cdnKey "<your key>" -
Restart your server.
If you host with us, you can edit server.cfg in the CFG editor in txAdmin, as shown in Deploying a Basic FiveM Server.
To check that it's working, run fileserver_list in your server console. You should see the FXCache URL listed.
It works with any framework, including ESX, QBCore, Qbox, VORP and txAdmin. There's no plugin, and players don't have to install anything. To stop using it, remove the two lines and restart.
What the two lines do
fileserver_addtells players where to download resources from. The pattern".*"matches every resource, so all downloads go through FXCache.adhesive_cdnKeysets a key that is used when your files are served, so every player receives the same copy of each file and the CDN only has to store one. The FiveM docs describe it as required to avoid corrupted cache entries.
Plans
The free plan needs no card and includes 1 server, 10 GB of storage, 1 TB of traffic and 1.5 million requests a month. Paid plans are Starter at $8 a month, Pro at $16 a month for 3 servers, and Network at $32 a month for 8 servers. Every plan has optional file protection, and paid plans add CDN storage for script images, video and fonts.
Get started with FXCache for free.
Get even faster joins
A CDN makes each download faster. These steps make the download smaller and spread out the load, so they work well alongside FXCache.
Remove unused resources
Only resources your server starts are sent to players, so anything you don't use should stop being started.
- Open
server.cfgand go through yourensureandstartlines. - Remove anything you no longer use. Watch out for lines that start a whole category folder, such as
ensure [cars], because they start everything in that folder. - Check for leftovers from a framework or recipe install, and for several resources that do the same job.
Optimise streamed assets
Streamed assets are the files in a resource's stream folder, and they usually make up most of the download. To find the worst offenders, download your resources over SFTP and sort them by size.
- YTD textures: Oversized textures are the most common problem. Resize textures that are far bigger than they need to be, for example a 4K texture on a small part, and keep them in a compressed format such as DXT1 or DXT5.
- Vehicles: Every add-on car adds to the download, including the ones nobody drives. Remove the ones you don't need, and replace very high-detail models with lighter versions.
- MLOs and maps: Remove interiors and map edits your server doesn't use. Check their texture files as well as the models, because they are often where the size is.
Your server console warns you about oversized assets when it starts. Those warnings are a good list to work through, and fixing them also helps with texture loss and in-game streaming problems.
If your in-game menus use large images or videos, load them from a web address when they are needed instead of including them in the resource. FXCache paid plans include CDN storage you can use for this.
Plan your restarts
When a server restarts, everyone who was online tends to rejoin at the same moment.
- Schedule restarts for quiet hours. txAdmin has a restart scheduler you can use for this.
- Try not to update large resources just before your busiest time. A changed file means everyone downloads it again, all at once.
- If you run a busy server, a connection queue spreads out how many players are loading at the same time.
Host close to your players
Put your game server in the region where most of your players are. FXCache takes care of download distance, but gameplay latency still depends on where the game server is.
What a CDN won't fix
A CDN only changes where the files come from. It won't help with:
- Player-side connection problems: A slow or unstable connection on the player's end will still be slow, and antivirus or firewall software can still get in the way.
- Broken resources: If a resource fails to load or a file is corrupt, the player will have the same problem. Fix the resource first. Your server console is the place to start.
- In-game lag from scripts: Heavy scripts affect performance after the player has joined. Use the
resmoncommand in the client console to find the ones using the most resources.
Does this apply to RedM?
Yes. RedM servers download resources the same way, so everything in this guide applies to them. FXCache works with RedM and frameworks such as VORP.