Start with a baseline
Measure before you optimize. Capture TTFB, LCP, and API latency by route so the team can prioritize high-impact work.
Layered cache strategy
Use cache layers by data volatility:
- Static or revalidated server content for marketing pages
- Per-tenant caching for dashboard shells
- On-demand revalidation for critical workflow updates
Route-level decisions
Treat each route independently. A global caching policy usually over-caches sensitive data or under-caches expensive queries.
Server actions in production
Server actions reduce boilerplate, but you should still enforce validation, auth checks, and audit logs in the action boundary.
"use server";
export async function updateWorkspaceName(name: string) {
await requireSession();
const cleanName = name.trim();
if (!cleanName) throw new Error("Workspace name is required");
return db.workspace.update({
where: { id: "current" },
data: { name: cleanName },
});
}Performance checklist
- Stream large pages where possible
- Keep client components focused and small
- Move data joins to the server layer
- Profile hydration on dashboard routes