June 6, 2025 ยท 1 min read ยท 248 words How I Sped Up the neon.tech Homepage from ~400ms to ~90ms Rishi Raj Jain @rishi_raj_jain_ share โ I recently optimized the performance of neon.tech (opens in a new tab) (by @neondatabase (opens in a new tab)) homepage and cut the TTFB from ~400ms to ~90ms: ๐ (TTFB numbers via @SpeedVitals (opens in a new tab)) Now, let's dive into magical changes below one by one: 1. Moved Real-Time Logic to Middleware 2. Removed Page Revalidation 3. Added Shared Cache Headers on Vercel 1. Moved Real-Time Logic to Middleware Previously, every request was SSR'd just to check if a user should be redirected to console.neon.tech. Now, this logic runs in a lightweight middleware using Next.js middleware (opens in a new tab), which performs runtime checks much more efficiently. 2. Removed Page Revalidation Disabled revalidation logic on the homepage and its alias /home: - export const revalidate = 60;+ export const revalidate = false; 3. Added Shared Cache Headers on Vercel Configured the cache headers in vercel.json to enable shared cache responses: { "source": "/", "headers": [ { "key": "Cache-Control", "value": "max-age=0, s-maxage=31536000" } ]},{ "source": "/home", "headers": [ { "key": "Cache-Control", "value": "max-age=0, s-maxage=31536000" } ]} ๐ Global Performance Results And that did the trick! Here's how the latency now looks globally (via @OpenStatusHQ (opens in a new tab)): Summary With just a few key changes: Middleware instead of SSR No revalidation Smart caching headers โฆwe got the homepage blazing fast! More posts 2 posts How to Implement Contextual Feature Flags in Angular using Unleash read โ9 Months of Customer Success at Polar read โ