Why a Filament panel feels slow on a Laravel server
Every Filament page takes several seconds to loadShort 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.
Fix it fast
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;"2Match what you see, then jump to its fix
- 1
Slowness grows with the number of resources, pages, widgets and relation managersFilament components and Blade Icons are not cachedFix - 2
The first-step command prints opcache.enable => 0 or nothingOPcache is switched offFix - 3
Slow on every route of the app, not only inside the panelLaravel's own config, route, event and view caches are missingFix
- 1
What does the error look like?
Every Filament page takes several seconds to loadThe panel is fast on a small demo and slow once there are many resources, pages and widgetsPage 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/filament2Fix
Run the Filament optimize command in your deployment script. It is shorthand for filament:cache-components and icons:cache.
php artisan filament:optimize3Verify
The folder now holds index files, and the panel loads faster on the next request.
ls bootstrap/cache/filamentConfirmed by filamentphp.com
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 --ini2Fix
Add opcache.enable=1 to the php.ini used by the web server, then restart PHP-FPM or Apache.
; php.ini
opcache.enable=13Verify
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
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/cache2Fix
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 optimize3Verify
Cached files appear in bootstrap/cache and the app answers faster.
ls bootstrap/cacheConfirmed by laravel.com
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
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
Intervention Image will not save the file in a Laravel app
Can't write image data to path (/var/www/app/public/uploads/photo.jpg)
Intervention Image writes straight to a file path.
3 causes, each with a fixBack end
Laravel file upload returns 413 behind nginx
413 Content Too Large
A 413 means a limit refused the request body before Laravel could use it.
3 causes, each with a fixBack end
Laravel says the bootstrap/cache directory must be present and writable
The /var/www/app/bootstrap/cache directory must be present and writable.
Laravel writes its package manifest into bootstrap/cache and throws when that folder is missing or the current user cannot write to it.
2 causes, each with a fixBack end
Carbon::now() and now() return the wrong hour in Laravel
created_at values do not match the local time
Carbon::now() uses the PHP default timezone, and Laravel sets that from app.timezone in config/app.php on every boot.
3 causes, each with a fixBack end
Laravel says Class "Redis" not found when using phpredis
Class 'Redis' not found
Laravel uses the phpredis PHP extension by default, so a missing or disabled extension gives Class "Redis" not found.
3 causes, each with a fix