How to clear the FiveM server cache, and when you should
What is in the cache folder of a FiveM server, when deleting it helps, how to do it safely, and how it differs from the player's cache.
Clearing the cache is the first thing people suggest for almost any FiveM problem. For players it sometimes helps. For the server it rarely does, because FXServer manages its cache folder on its own. Here is what is in it and when deleting it makes sense.
What is in the server cache folder
FXServer creates a folder called cache in your server data folder, the one that holds your server.cfg. If you use txAdmin, it is the server data folder shown in txAdmin's settings. Inside cache/files there is a folder for each resource with:
- resource.rpf, a package with the resource's client and shared scripts and everything listed under files in its fxmanifest. Players download this package for the non-streamed part of the resource.
- A small database file that records which source files went into the package.
- resource.sfl, the list of streamed files from the resource's stream folder, and sometimes a stream_cache folder with converted copies of them.
Every time a resource starts, the server checks whether the package still matches the files in the resource. If anything changed, it builds a new one. So when you update a resource and restart it, the cache updates itself.
When clearing it helps
- A resource keeps loading an old or broken version after a restart. This is rare, but a crash or a full disk while the server was building a package can leave a bad one behind.
- You removed a lot of resources and want the disk space back. The server does not delete the cache folders of resources that no longer exist.
- You moved the server to another machine and want a clean start.
It does not fix lag, script errors or players crashing. Those have other causes, and the server builds the same cache again on the next start.
How to clear it safely
- Stop the server. In txAdmin, use Stop Server. Deleting files while the server is running can break a package it is writing.
- Open your server data folder and delete the cache folder. Leave resources, your server.cfg and your database alone. Those are your actual server.
- Start the server again. The first start takes longer because every resource is packed again.
Players may download the rebuilt packages again on their next join, so do this outside your busiest hours.
The player's cache is a different thing
Players have their own cache on their PC, under %LocalAppData%\FiveM\FiveM.app\data. The server-cache and server-cache-priv folders hold files downloaded from servers. Clearing those can fix missing textures or a client that keeps using a broken download. They should leave the game folder inside cache alone. It holds GTA V files that FiveM needs, and downloading them again takes a long time.
Be careful with telling your whole community to clear their cache. Every player who does it downloads all of your resources again on their next join. With a 5 GB server and a few hundred players, that is a lot of traffic in a short time, and it all comes from your server unless you use a CDN.
Clearing a CDN cache
If your downloads go through a CDN, there is a third cache. With FiveMCDN you normally never need to clear it. Our own invalidation system picks up changed files automatically, and unchanged files keep coming from the cache. For the rare case where you want a clean start, every server in your dashboard has a Purge cache button. See cache invalidation in the docs, or read how server-side resource caching works.