Lighthouse 95+ in PHP — the checklist we run on every deployment
33 points: OPcache, Octane, Redis, nginx, fonts, images, JS and Core Web Vitals. Concrete settings from our PHP/Laravel deployments, no generalities.
The examples are Laravel because that’s what most of our projects run on, but the rules carry over to any PHP stack. The order is deliberate: server and database first, because no front-end tuning makes up for a one-second TTFB.
Backend / server
- PHP 8.3+ with OPcache —
opcache.enable=1,opcache.memory_consumption=256, and in productionopcache.validate_timestamps=0(then you must restart PHP-FPM after every deploy, or it keeps serving old code). JIT (opcache.jit=1255+opcache.jit_buffer_size) does little for a typical web app, because the time goes to the database and I/O, not computation. - Laravel Octane (Swoole / RoadRunner) — the framework boots once per worker instead of on every request. The catch: your code must not keep state in static properties and singletons between requests.
- Redis for cache, sessions and queue instead of the
databaseandfiledrivers. - Eager loading —
with(['relation1', 'relation2'])on every list to avoid N+1.Model::preventLazyLoading()in local development catches it immediately. - Database indexes on columns used in frequent
WHERE,JOINandORDER BYclauses — verified withEXPLAIN, not added blindly everywhere.
HTTP / nginx
- HTTP/2 — on nginx 1.25.1+
http2 on;(older syntax:listen 443 ssl http2). HTTP/3 (QUIC) where the server and CDN support it. - Brotli compression —
brotli on; brotli_comp_level 6;(requires thengx_brotlimodule). gzip onas a fallback for clients without Brotli.- Cache headers —
expires 1y; Cache-Control "public, immutable"for hashed assets. - HSTS —
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload. The browser goes straight to HTTPS without the HTTP redirect.
Frontend
- Self-hosted fonts instead of Google Fonts — no connections to
fonts.googleapis.comandfonts.gstatic.com. - Preload fonts used above the fold:
<link rel="preload" href="/fonts/inter-700.woff2" as="font" type="font/woff2" crossorigin>. font-display: swapin@font-face.widthandheighton every<img>— the browser reserves the space, no CLS.loading="lazy"on images below the fold — never on the LCP image.fetchpriority="high"on the LCP image.
Images
- WebP / AVIF instead of JPG/PNG.
srcsetandsizes— a phone shouldn’t download a file sized for a 4K monitor.- Sharp in the build pipeline or on upload.
- Image CDN (Cloudflare Images, imgix or your own).
JS / CSS
- Tree shaking — Vite / Webpack keep only the code you use.
- Critical CSS inline in
<head>, the rest loaded asynchronously. <script defer>or<script type="module">for anything not needed for the first render.- Code splitting — each page loads only its own JS.
asyncon third-party scripts (analytics, chat widgets). Each one is a deliberate decision, not a default add-on.
Core Web Vitals
- LCP < 2.5 s — preload the main image and font, fast server response.
- CLS < 0.1 — sized images,
aspect-ratioon containers, fonts withswapand a matched fallback. - INP < 200 ms — debounced handlers, virtualised long lists, heavy work in a Web Worker.
- TTFB < 600 ms — Octane, Redis cache, edge cache (Cloudflare proxy).
After deployment
- Lighthouse CI in the pipeline — the build fails if the score drops below 90.
- Real user monitoring — Sentry Performance or Cloudflare Web Analytics.
- WebPageTest once a month from several locations.
- Search Console Core Web Vitals report — field data from real users’ browsers, not lab data.
From our deployments
The typical picture on PHP projects that go through this list:
- before: Lighthouse 50–70, LCP 4–7 s,
- after: Lighthouse 95–100, LCP 0.5–1.5 s.
An audit with optimisation takes 1–3 days, depending on how much needs fixing in the database and how many third-party scripts can be removed. If you’d like us to go through this list on your site, get in touch.
Dealing with something similar?
Tell us how it looks in your store or warehouse. The quote is free, we sign an NDA by default and reply within 24 business hours.
Let's talk →