Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Why a Filament panel feels slow on a Laravel server

ErrorEvery Filament page takes several seconds to load

Short answer

A slow Filament panel on a server is most often running without the production caches. Run php artisan filament:optimize to cache components and icons, php artisan optimize for config and routes, and check that OPcache is on. Do not run the component cache on a dev machine, because new files will not be found.

  • Applies to Filament 4, Laravel 12, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask PHP whether OPcache is enabled. The Filament deployment guide gives this exact check, and the answer should be 1.

    php -r "echo 'opcache.enable => ' . ini_get('opcache.enable') . PHP_EOL;"
  2. 2Match what you see, then jump to its fix

    1. 1Slowness grows with the number of resources, pages, widgets and relation managersFilament components and Blade Icons are not cachedFix
    2. 2The first-step command prints opcache.enable => 0 or nothingOPcache is switched offFix
    3. 3Slow on every route of the app, not only inside the panelLaravel's own config, route, event and view caches are missingFix

What does the error look like?

  • Every Filament page takes several seconds to load
  • The panel is fast on a small demo and slow once there are many resources, pages and widgets
  • Page time is high even when the database queries are quick

Cause 1 of 3

Filament components and Blade Icons are not cached

1Check

Without the cache Filament has to scan your app files to discover components, and Blade Icons are slow when uncached. See whether the cache folder exists.

ls bootstrap/cache/filament

2Fix

Run the Filament optimize command in your deployment script. It is shorthand for filament:cache-components and icons:cache.

php artisan filament:optimize

3Verify

The folder now holds index files, and the panel loads faster on the next request.

ls bootstrap/cache/filament

Confirmed by filamentphp.com

Did this fix it?

Cause 2 of 3

OPcache is switched off

1Check

OPcache keeps compiled PHP in memory. Without it every request compiles the whole framework and Filament again. The CLI and the web server can use different ini files, so also check the one PHP-FPM or Apache loads.

php --ini

2Fix

Add opcache.enable=1 to the php.ini used by the web server, then restart PHP-FPM or Apache.

; php.ini
opcache.enable=1

3Verify

Run the first-step command again and expect opcache.enable => 1.

php -r "echo 'opcache.enable => ' . ini_get('opcache.enable') . PHP_EOL;"

Confirmed by filamentphp.com

Did this fix it?

Cause 3 of 3

Laravel's own config, route, event and view caches are missing

1Check

Laravel rebuilds its configuration and route list on each request unless they are cached. A project that was only copied to the server has none of these caches.

ls bootstrap/cache

2Fix

Run optimize as part of every deploy. After config:cache, call env() only inside config files, because .env is no longer read and env() returns null elsewhere.

php artisan optimize

3Verify

Cached files appear in bootstrap/cache and the app answers faster.

ls bootstrap/cache

Confirmed by laravel.com

Did this fix it?

How do I stop it coming back?

  • Put php artisan filament:optimize and php artisan optimize in the deploy script so they run on every release.
  • Do not run filament:cache-components on a development machine; clear it with php artisan filament:optimize-clear if you did.
  • Read env() only in config files so cached config keeps working.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.