Performance: Database configuration
This affects the initial page load speed and backend response time by controlling how the application connects and queries the database.
Use Laravel's built-in connection pooling and caching with config/database.php and .env settingsDB::connection()->getPdo(); // called repeatedly without connection pooling or caching| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated new DB connections per request | N/A | N/A | N/A | [X] Bad |
| Persistent DB connections with config caching | N/A | N/A | N/A | [OK] Good |
.env file in Laravel's database configuration?.env file?.env snippet:DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=mydb DB_USERNAME=user DB_PASSWORD=pass
.env file:DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=myapp DB_USERNAME=root DB_PASSWORD=
Pass the test and this pattern moves unknown