A Deep Dive into Modern Web Performance
1 February 2025 - Francis Agbey · Updated 17 October 2026

On this page
Why Performance Is a Product Problem
Performance is a product decision made throughout a build: how much work a page asks the browser to do, when data becomes available, and how quickly a user can complete a task. Measure those behaviors on the devices and connections your audience actually uses.
"The best performance optimization is the one you don't have to undo." — Internal design principle
The Stack We Optimise
The following is an illustrative architecture for discussing performance trade-offs, rather than a claim that every AgbeyTech project uses this stack:
- Next.js 15 with App Router and React Server Components
- PostgreSQL via Prisma, co-located with compute on Fly.io
- Redis for query-level caching
- Cloudflare as the global edge layer
- Vercel for preview deployments
Server Components vs Client Components
The golden rule: render on the server unless you need interactivity.
// app/blog/page.tsx — server-side data access
export default async function BlogList() {
const posts = await db.post.findMany({ orderBy: { date: "desc" } });
return (
<ul>
{posts.map((p) => (
<li key={p.id}>{p.title}</li>
))}
</ul>
);
}
// ⚠️ Only go client when you need state / events
("use client");
export function LikeButton({ postId }: { postId: string }) {
const [liked, setLiked] = useState(false);
return (
<button aria-pressed={liked} onClick={() => setLiked((l) => !l)}>
{liked ? "Liked" : "Like"}
</button>
);
}Caching Strategy
We apply caching in three layers:
- In-memory — React's built-in
cache()for request deduplication - Redis — 60-second TTL on expensive aggregation queries
- CDN edge —
Cache-Control: s-maxage=300, stale-while-revalidate=600on static routes
| Layer | Scope | TTL | Invalidation |
|---|---|---|---|
cache() |
Per request | Auto | N/A |
| Redis | Cross-request | 60–300 s | On mutation |
| CDN edge | Global | 5 min | Purge API |
Route Segment Config
Next.js gives us fine-grained control at the file level:
// app/dashboard/page.tsx
export const revalidate = 60; // ISR — rebuild at most every 60 s
export const dynamic = "force-dynamic"; // opt out when data is always freshFor a route that must be rendered on every request, use dynamic = "force-dynamic" instead of the revalidation example above. These are alternative strategies, not settings to combine for a time-cached page. Route configuration also depends on the Next.js version and caching mode; consult the route segment configuration reference.
Image Optimisation
The Image component helps with:
- Serves optimized image formats according to configuration and browser support
- Generates
srcsetfor responsive loading - Lazy-loads below-the-fold images by default
- Prevents Cumulative Layout Shift with explicit
width/height
import Image from "next/image";
<Image
src="/hero.jpg"
alt="Hero image"
width={1280}
height={720}
priority
sizes="(max-width: 768px) 100vw, 50vw"
/>;Note: Always set
priorityon your LCP image, and never on below-the-fold images.
Measuring What Matters
Core Web Vitals are the production target:
- LCP (Largest Contentful Paint) — good at ≤ 2.5 s
- INP (Interaction to Next Paint) — good at ≤ 200 ms
- CLS (Cumulative Layout Shift) — good at ≤ 0.1
Use real-user measurements where available and evaluate the 75th percentile. The Core Web Vitals guidance defines the metrics and thresholds; local lab tests complement that evidence but do not replace it.
Takeaways
- Reach for Server Components first
- Cache aggressively, invalidate precisely
- Optimise images at the framework level, not post-hoc
- Measure real-user data, not just Lighthouse synthetic audits
Have questions? Reach out