Skip to content

Route Caching

Reflecting over controller classes on every request adds overhead. Route caching compiles the route map once and stores it as a plain PHP file.

$cachePath = __DIR__ . '/../storage/cache/routes.php';
if (file_exists($cachePath)) {
$router->loadFromCache($cachePath);
} else {
$router->register(UserController::class);
$router->register(PostController::class);
$router->saveToCache($cachePath);
}

When using the full Antares framework, caching is handled automatically. Set APP_ENV=production in your .env and the cache is built on first request and invalidated whenever composer.lock, .env, or any file under app/ changes.

Clear the cache manually:

Terminal window
php bin/antares cache:clear