Performance: Cache configuration
Cache configuration affects how fast Laravel serves repeated requests by storing data to avoid repeated processing.
<?php // Cache query results for 10 minutes $users = Cache::remember('users.all', 600, fn() => DB::table('users')->get());
<?php
// No caching, query runs on every request
$users = DB::table('users')->get();| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No cache (DB query every request) | N/A | N/A | High server delay delays paint | [X] Bad |
| File cache driver | N/A | N/A | Moderate server delay delays paint | [!] OK |
| Redis cache driver with query caching | N/A | N/A | Minimal server delay, fast paint | [OK] Good |
config/cache.php file?config/cache.php:
'stores' => [
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
],
'default' => 'redis',
What cache store will Laravel use by default?.env but Laravel still uses the file cache. What is the most likely cause?php artisan config:clear clears cached config, allowing new .env values to take effect.php artisan config:clear -> Option Aconfig/cache.php settings correctly achieves this?Pass the test and this pattern moves unknown