Laravel · Performance
How to Make a Laravel Website Load in Under 2 Seconds
A practical checklist to make a Laravel website load in under 2 seconds: caching, query tuning, eager loading, images, fonts and Core Web Vitals fixes.
By Ehsan Ullah · Published · Last updated · 6 min read
Why does a 2-second load time matter?
Google uses Core Web Vitals as part of its ranking signals, and visitors abandon slow pages. A good target for a Laravel website is a Largest Contentful Paint (LCP) under 2 seconds on mobile, an INP under 200 ms and almost no layout shift. Hitting that needs work on both the server and the browser side.
1. Make the server respond fast
The browser cannot start rendering until the HTML arrives, so Time to First Byte comes first.
- Cache configuration and routes in production:
php artisan config:cache,route:cache,view:cacheandevent:cache. - Enable OPcache with sensible memory limits.
- Use Redis (or at least the file driver) for cache and sessions instead of the database.
- Cache expensive queries and fragments with
Cache::remember()and clear them on model events. - Queue slow work such as emails, PDF generation and API calls, so the request returns immediately.
2. Fix the database
Most slow Laravel pages I audit are slow because of the database.
- Kill N+1 queries with eager loading (
with()), and enableModel::preventLazyLoading()in development to catch them. - Add indexes for columns used in
where,orderByand joins. Check withEXPLAIN. - Select only the columns you need and paginate large lists.
- Watch queries with Laravel Debugbar or Telescope during development.
3. Ship less to the browser
- Compress images to WebP or AVIF, serve correct sizes with
srcset, and setwidthandheightto prevent layout shift. - Lazy-load below-the-fold images; preload the hero image.
- Bundle with Vite and remove unused CSS (Tailwind does this automatically).
- Defer non-critical JavaScript and third-party tags; load chat widgets after the page is interactive.
- Self-host fonts, subset them, use
font-display: swapand limit weights.
4. Use the network well
- Serve over HTTP/2 or HTTP/3 with Brotli compression.
- Put static assets behind a CDN with long cache headers and hashed file names.
- Use full-page caching for public pages that rarely change.
5. Measure before and after
Test with PageSpeed Insights and Lighthouse, then confirm with real-user data in Google Search Console. Change one thing at a time so you know what worked.
Quick checklist
| Area | Action |
|---|---|
| Server | Config, route and view caching, OPcache, Redis |
| Database | Eager loading, indexes, pagination |
| Assets | WebP/AVIF, lazy loading, Vite, deferred JS |
| Network | HTTP/2+, Brotli, CDN, cache headers |
Need a faster site? See website speed optimization or Laravel development.