Free FiveM cache cleaner

Cache Clean documentation

Clears your FiveM server cache automatically every time the server starts or restarts (txAdmin scheduled restarts included). No more "I updated the script but players still get the old version".

  • Standalone: any framework (QBCore, Qbox, ESX, vRP, none), Windows and Linux.
  • Safe: it only deletes the cache of resources that haven't started yet. txAdmin's monitor, itself and anything already running are never touched.
  • Three modes: always (every start), next (only the next start, then it switches itself off) and off.
  • Console command: cacheclean <always|next|off> changes the mode without editing files (saved in state.json).
  • 0.00 ms: it works once, at start, and then does nothing.
  • Console messages in Spanish or English.
  • Version 1.0.1
  • Requirements: FXServer build 35245+ (any build for the script itself). Nothing else: no framework, no database, no OneSync, no other ROLO SCRIPT resource.
  • No lock-in: it is a standalone free script; no other ROLO SCRIPT resource is needed or used.

What's new in 1.0.1: shell hardening. The script has to use the operating system to list and delete folders (FiveM's Lua has no folder API), so every path and folder name is now validated before it can reach the shell: Config.CachePath only accepts letters, numbers and _ - . / \ : and spaces (nothing is deleted otherwise), and a cache folder is only deleted when its name is made of letters, digits, _, - and .. No config changes.

Installation

  1. Put rolo_cacheclean in your resources folder.
  2. In server.cfg, add it as the FIRST ensure, before every other resource:
    ensure rolo_cacheclean
    
    It has to start before the others, so it can clear their cache before they are loaded.
  3. Restart the server. In the console you'll see: [rolo_cacheclean] Cache cleared: 84 resource(s) in 312 ms.

Configuration (config.lua)

Option What it does
Config.Mode 'always', 'next' or 'off' (the console command overrides it).
Config.CachePath The cache folder, relative to your server-data folder (default 'cache'). Only letters, numbers, _ - . / \ : and spaces are accepted.
Config.Keep Resources whose cache is never cleared (default: txAdmin's monitor).
Config.Locale 'es' or 'en'.

Tips

  • Clearing the cache on every start is not required for FiveM to work: it rebuilds changed files by itself. It only makes the boot a bit slower. If you prefer, use Config.Mode = 'next' and run cacheclean next in the console right after updating scripts; the next restart clears it once.
  • If your host doesn't allow listing folders (io.popen), the console tells you: clear it by hand (txAdmin → Stop → File Manager → delete cache → Start).
  • The warning "resource(s) were already running" means ensure rolo_cacheclean isn't the first one in server.cfg.

Integrations / Custom

This is a standalone script with nothing to plug into: no exports, no events and no hooks. Everything is adjustable from config.lua and from the console:

What How
When the cache is cleared Config.Mode ('always' / 'next' / 'off') or the console command cacheclean <always|next|off> (saved in state.json; admins with the command.cacheclean ace or the console)
Where the cache is Config.CachePath (relative to the folder where server.cfg is)
What is never touched Config.Keep (resource names) plus this resource and anything already running
Language of the console messages Config.Locale ('es' / 'en'); the texts themselves are in the TEXT table at the top of server.lua

Escrow: what is open

Nothing is escrowed. It is free and open source: config.lua and server.lua are listed in escrow_ignore in fxmanifest.lua, so you can read and change both. server.lua explains at the top why it uses the system shell and how every value is validated first.

Support

ROLO SCRIPT · roloscript.com

Stuck?

Write to us in the Discord support channel with the script, your framework and the console error.