June 6, 2025 1 min read 223 words

How I Sped Up the neon.tech Homepage from ~400ms to ~90ms

I recently optimized the performance of neon.tech (by @neondatabase) homepage and cut the TTFB from ~400ms to ~90ms:

Before and After Latency Report

๐Ÿ“Š (TTFB numbers via @SpeedVitals)

Now, let's dive into magical changes below one by one:


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:

- 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): Global Latency Report

Summary

With just a few key changes:

  • Middleware instead of SSR
  • No revalidation
  • Smart caching headers

โ€ฆwe got the homepage blazing fast!

Thanks for reading

If this was useful, sharing it on X helps a lot. Spotted a typo or want to push back? DM me.