June 6, 2025 ยท 1 min read ยท 225 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 (by @neondatabase) homepage and cut the TTFB from ~400ms to ~90ms: ๐ (TTFB numbers via @SpeedVitals) 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, which performs runtime checks much more efficiently. 2. Removed Page Revalidation Disabled revalidation logic on the homepage and its alias /home: Wrap- 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: Wrap{ "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): 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 SEO Optimization for Client Side Rendered Next.js Apps read โ9 Months of Customer Success at Polar read โ