Skip to content

Move compiled directories to their own path for better caching - #707

Open
janhenckens wants to merge 3 commits into
developfrom
feature/move-compiled-dirs-for-caching
Open

janhenckens wants to merge 3 commits into
developfrom
feature/move-compiled-dirs-for-caching

Conversation

@janhenckens

@janhenckens janhenckens commented Sep 15, 2026

Copy link
Copy Markdown
Member

On each request, both frontend and control panel, Craft reads the compiled_classed and compiled_templates directories. If we can make reading these directories faster, we should be able to improve performance.

Combell packages with 50GB and higher have a "RAM Disc" feature, a way to speed up reading & writing files. If we can move these folder to such a RAM disc, that should speed things up. However, this virtual disc is not unlimited in size (default is 256MB max) and it acts like a real disc, meaning that if it's full it will throw an error.

In a default Craft install, these folders are located in storage/runtime, along side temp, assets, debug, mutex, ... and to enable this feature for a hosting package we need to set a path at which the server should "place" the virtual disc.

If we were to put the entire storage/runtime dir in the RAM disc, we run the risk of storage/runtime/temp filling up (depending on the project of course, with temp uploads, generated exports, etc) and cause an a breaking error.

This PR tries to solve that by moving the 2 compiled directories out of storage/runtime and into their own (custom) storage/appcache folder, allowing us to configure that path as the virtual drive.

We also keep the appcache dir in the folder shared across deploys so we do with the regular storage/runtime directory.

The service only moves the directories when the related environment variable CRAFT_COMPILED_PATH="" is set and this runs without error and across environments regardless of the variable being set and the RAM disc being enabled.

@Numkil @HannahDeWachter @SarahOorts @kristofser Could you have look to see if this makes sense?

@sonarqubecloud

Copy link
Copy Markdown

@janhenckens
janhenckens marked this pull request as ready for review September 15, 2026 18:25
@kristofser

Copy link
Copy Markdown
Member

@janhenckens Is there an option to clear that cache via a command? Backend setting?
Something to quickly clear cache when needed (to eg. clear for stale/old cache files that aren't needed anymore..

@janhenckens

Copy link
Copy Markdown
Member Author

Is there an option to clear that cache via a command? Backend setting? Something to quickly clear cache when needed (to eg. clear for stale/old cache files that aren't needed anymore..

@kristofser Craft has a command and a UI to clear those caches and that all works as it would without this change and with or without the RAM disc. Clearing it from the Combell side or the filesystem itself is not possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants