DefLoadCache
DefLoadCache caches the result of RimWorld's XML def loading and patch application, so repeat launches with the same mod list skip the two slowest stages of startup.
On a 414-mod list, this cuts launch time from ~9 minutes to ~2:40 after the first launch.
How RimWorld loads mods
When RimWorld launches with mods, it runs through a pipeline of stages. The relevant ones for def loading:
[list]
[*] [b]Mod discovery[/b] — scans Mods/ and Steam workshop for active mods
[*] [b]Assembly load[/b] — loads each mod's DLLs
[*] [b]LoadModXML[/b] — reads every Defs/*.xml file from every mod into memory
[*] [b]CombineIntoUnifiedXML[/b] — merges all parsed XML into one XmlDocument
[*] [b]ApplyPatches[/b] — runs every Patches/*.xml file via XPath against the unified doc
[*] [b]ErrorCheckPatches[/b] — validates patches succeeded
[*] [b]ParseAndProcessXML[/b] — converts XmlNode into typed Def objects
[*] [b]ResolveReferences[/b] — links cross-def references
[*] [b]Texture, audio, string loading[/b] — Unity loads mod assets
[/list]
On a 414-mod list, stages 3 and 5 (LoadModXML + ApplyPatches) alone account for about 6 of the 9 minutes. They also produce the same result every launch if nothing changed.
What DefLoadCache does
DefLoadCache skips stages 3, 5, 6, and 8 on cache-hit launches. It serializes the fully-patched XmlDocument to disk after a normal first launch, then streams the cached document back on subsequent launches in place of re-reading files and re-running patches.
The cache invalidates automatically when anything affecting def content changes. A SHA-256 fingerprint is computed per file across every mod's Defs/, Patches/, Assemblies/, and About.xml. Any byte-level change to any of those files flips the fingerprint and forces a rebuild. Mod additions, removals, reorders, version changes, RimWorld updates, and DLL rebuilds all trigger rebuilds.
Stages that still run every launch regardless of cache state: texture/audio/string loading, ParseAndProcessXML, ResolveReferences, Harmony patching, and static constructors. These account for the ~2:40 of launch time that remains on cache hits.
Performance
Measured on a 414-mod Combat Extended milsim load order:
[list]
[*] First launch (builds cache): [b]~9:10[/b] — normal speed plus a few seconds to serialize
[*] Subsequent launches (cache hit): [b]~2:40[/b] — [b]71% faster[/b]
[*] Cache size on disk: ~7 MB
[/list]
When anything changes (mod added, updated, removed, reordered), the next launch runs a full rebuild at ~9 minutes and the cycle starts again.
Benefits most from an SSD and 16 GB+ RAM. Older hardware still works but sees smaller gains because the cache read is competing with other disk I/O.
When to use DefLoadCache vs MissileGirl
MissileGirl is a comprehensive performance suite. Gagarin (XML def caching), RocketMan (stat/thing caching), Soyuz (pawn tick throttling), Cosmodrome (patch optimization), and a texture cache. If you want one mod that addresses many performance pain points at once, MissileGirl is generally the stronger pick. It does more than DefLoadCache does.
DefLoadCache focuses on one thing: the XML def pipeline. It overlaps with Gagarin at that specific stage, so running both is redundant. The rest of MissileGirl's subsystems (stat caching, pawn throttling, texture cache) don't touch XML loading and can run alongside DefLoadCache without issue. You can do only use one. If you prefer the other stuff provided by MissileGirl, please use MissileGirl
Pick DefLoadCache specifically if:
[list]
[*] You want only the XML caching without MissileGirl's broader changes to stats, pawn ticks, patches, and textures. Smaller surface area means fewer interaction points with other mods.
[*] You've hit compatibility issues with MissileGirl's non-XML subsystems.
[*] You want the cache to persist as long as nothing changes. Gagarin auto-expires its cache after 2 days even if your mod list is untouched; DefLoadCache doesn't.
[/list]
Compatibility at a glance
[list]
[*] [b]FasterGameLoading[/b] (Taranchuk / mushroomTW continued): stackable. Operates on different pipeline stages (reflection caching, graphics deferral, atlas baking). FGL's own About.xml lists DefLoadCache under "works well with."
[*] [b]Image Opt[/b] (soeur): stackable. Operates on texture decoding only.
[*] [b]Performance Fish[/b] (bbradson): stackable, no known conflicts.
[*] [b]MissileGirl[/b] (ViralReaction): Not compatible. You cannot disable MissileGirl’s caching
[*] [b]HugsLib[/b]: stackable.
[*] [b]Harmony, Prepatcher[/b]: required dependencies.
[/list]
FAQ
[b]Q: Does this do the same thing as FasterGameLoading?[/b]
No. FasterGameLoading optimizes runtime reflection, graphics deferral, and texture atlas baking. It doesn't cache parsed defs or patched XML to disk. DefLoadCache targets the XML loading and patch application stages specifically. They operate on different parts of the launch pipeline and can be installed together.
[b]Q: Why did my cache invalidate after a Steam workshop update?[/b]
On older versions, any file modification timestamp change triggered a rebuild, which included Steam re-downloads even when content was byte-identical. The current version uses SHA-256 content hashing, so a Steam update that doesn't actually change file contents no longer invalidates the cache.
[b]Q: Can it corrupt my save?[/b]
No. DefLoadCache only affects how defs are loaded at game launch. It doesn't read or write save files. If loaded defs are wrong, you'd see errors at game startup, not after loading a save.
[b]Q: Can it break other mods?[/b]
It shouldn't, the cached XmlDocument is byte-equivalent to what a normal launch produces. Every cache hit runs a validation check comparing per-mod def counts against a baseline. A mismatch triggers auto-delete and a clean rebuild on the next launch. If you're debugging another mod, click "Test without cache (next launch only)" in DefLoadCache's settings to isolate the issue.
[b]Q: I'm developing a mod. Will this interfere?[/b]
The cache invalidates on any file change, so it'll just rebuild when you edit a Def or Patch. If you want to disable the cache entirely during development, toggle off "Skip reading mod files on repeat launches" in settings.
[b]Q: Works with RimPy, RimSort, or manual mod management?[/b]
Yes. DefLoadCache fingerprints whatever mods are active regardless of how they got there. Each mod list configuration gets its own cache automatically.
[b]Q: Where are the cache files stored?[/b]
In your RimWorld save data folder under DefLoadCache/. You can see the exact path and manage cache files from the mod settings page.
Requirements
[list]
[*] [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2934420800]Prepatcher[/url] (required dependency)
[*] RimWorld 1.6
[*] Place anywhere in your mod list after Prepatcher and Harmony
[/list]
Source Code
[url=https%3A%2F%2Fgithub.com%2FFluxxField%2Frimworld-defload-cache]GitHub[/url][github.com].
Credits
[list]
[*] [b]FluxxField[/b] — author
[*] [b][url=https://steamcommunity.com/workshop/filedetails/?id=2009463077]Harmony[/url][/b] by Brrainz — the patching library that Prepatcher and most RimWorld mods are built on
[*] [b][url=https://steamcommunity.com/sharedfiles/filedetails/?id=2934420800]Prepatcher[/url][/b] by Zetrith — the [FreePatch] IL injection system that makes this possible. Thanks to Jikulopo for maintaining a fork while Zetrith was away.
[*] [b][url=https%3A%2F%2Fgithub.com%2Fkrafs%2FPublicizer]Krafs.Publicizer[/url][github.com][/b] — compile-time publicizer for accessing internal Cecil types
[*] [b][url=https%3A%2F%2Fgithub.com%2Fbbradson%2FPerformance-Fish]Performance Fish[/url][github.com][/b] by bbradson — inspiration for the Publicizer + HintPath pattern
[/list]