Website Speed Optimization Beyond Image Compression
Everyone compresses images. Winners fix the request waterfall, caching layers, and database queries behind slow TTFB. Speed is a system property—CDN + app + DB + third parties.
Front-End Wins
- HTTP/2 or HTTP/3 with TLS 1.3
- Critical CSS inlined, rest deferred
- JS budget: under 200KB gzipped for marketing pages
- Service worker caching for repeat visits on PWAs
Backend and Infrastructure
Enable OPcache in PHP, Redis object cache for WordPress/Laravel query results. Database: explain slow queries, add composite indexes matching WHERE + ORDER BY. Full-page cache for anonymous HTML at nginx or Cloudflare—bypass cache only for authenticated cookie sessions.
# nginx microcache for anonymous pages
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=APP:100m inactive=60m;
fastcgi_cache APP;
fastcgi_cache_valid 200 5m;
fastcgi_cache_bypass $cookie_session;
fastcgi_no_cache $cookie_session;
Measurement
Track p95 TTFB and LCP in Grafana from RUM beacon. Synthetic checks from multiple regions catch CDN misconfiguration. Target under 1.5s fully loaded on 4G for primary landing pages.
CDN and Edge Strategy
Cache static assets with immutable headers—filename hashing in webpack/vite enables Cache-Control: max-age=31536000, immutable. HTML stays short TTL or stale-while-revalidate for semi-static marketing pages.
Origin shield and tiered cache reduce load on primary server during viral traffic. Configure purge API hooks in deploy pipeline so content updates invalidate edge within 60 seconds, not hours.
Database connection pooling and query cache are not interchangeable—pooling reduces connection overhead; Redis query cache helps read-heavy dashboards. Profile before applying both blindly.
Warm critical caches after deploy with synthetic traffic hitting top 20 URLs—cold cache on high-traffic landing page right after release causes temporary CWV spike visible in field data for days. Automate warm-up script in deploy pipeline final step.
Third-Party Audit
Tag managers load analytics, chat, heatmaps— cumulative main thread block often exceeds in-house JS bundle. Require business case for each tag with owner and retirement date. Unused Hotjar from 2021 still loads on every page visit costing speed and privacy compliance risk.
Negotiate SLAs with vendors hosting embeds—slow support widget iframe dragging LCP is their problem architecturally but your problem in Search Console field data affecting rankings.
Audit tag managers quarterly—unused analytics and heatmap scripts from years ago still block the main thread. Require owners and retirement dates for every third-party embed affecting production pages.
HTTP Caching Headers
Immutable cache for hashed assets, short TTL for HTML, stale-while-revalidate for semi-static API JSON feeds. Misconfigured Cache-Control: no-store on static assets by framework defaults wastes CDN budget—audit headers in production with RED or curl -I spot checks weekly.
Preconnect to critical third-party origins only—excessive preconnect wastes connection limits browsers enforce per host. dns-prefetch for analytics domains loads later after first paint when marketing insists on tag presence eventually anyway.
Enable Brotli at CDN and origin for text assets—20% smaller than gzip on HTML and JSON at negligible CPU cost modern hardware. Verify Accept-Encoding negotiation in production not just curl localhost tests missing CDN layer behavior entirely misleading.
Split critical CSS manually or via tooling for above-fold content—automatic extraction imperfect but better than blocking 200KB stylesheet before first paint on landing pages paid ads drive traffic toward conversion.
Test from Lahore, London, and Virginia monthly—single-region lab scores mislead global products. CDN helps static assets, but origin geography still dominates TTFB for dynamic HTML unless edge caching is configured deliberately.
Save WebPageTest filmstrip URLs in release notes when major perf work ships—visual proof helps stakeholders understand changes beyond abstract millisecond deltas alone.
Multi-Region Testing
Run speed tests from Lahore, London, and Virginia monthly—single-region lab tests mislead global prioritization. Warm CDN caches after deploys so launch-day traffic does not hit cold origin.
Enable Brotli at CDN and origin for HTML and JSON—typically twenty percent smaller than gzip with negligible CPU cost on modern hardware.
Frequently Asked Questions
Cloudflare orange cloud enough?
Helps static assets and DDoS. Dynamic HTML still needs origin optimization—do not set cache everything blindly.
Lazy loading all images?
Lazy load below-fold only. LCP image must load immediately with fetchpriority high.
WordPress specific tip?
Disable unused plugins, use object cache, limit post revisions, offload media to S3.