Post

Small detail about the new Planetscale homepage, there's no pop in for their Sign in / Dashboard link, it's included in first HTML payload that's sent to the client A dive into how this works and why it's interesting (sub 50ms SSRing!)

First, a quick look at the tech stack Wappalyzer says it's Next and Remix, inspecting the HTML payload which is what we care about, it's using Remix

Next up, the response headers what can we learn from those? They're SSRing each page load, you can tell this by how the age is 0 and the X-Vercel-Cache is MISS. Along with this, the site is hosted on Vercel meaning they're either using serverless functions or edge functions

Loading the page from us-west it loads in 50ms-100ms Swapping my location with a VPN to Australia, the initial HTML takes 200-250ms to load This makes me think they're SSRing on the edge as if you compare those numbers to remix-on-the-edge.vercel.app/edge they're very similar

Looking at the auth cookie, I think they're using JWTs for auth which should mean they're able to skip doing a DB lookup for the user and so the only executing cost they're paying is the trip from the client to the edge function and back

0 reposts1 like

Overall this is a really good implementation, it's flexible where if they need to add more dynamic elements they can, and also they can do page view tracking in the edge functions to get accurate view counts Edge functions are essentially free and it adds to their polish

There is one small improvement that could be made if they were using Next (probably possible in Remix too, don't know the implementation though) By using middleware.ts instead of doing the dynamic content in the page itself, their content would be able to be cached

This pattern has it's own tradeoffs though, as it's less flexible and now you have to maintain two page files You still have to hit an edge function, although edge middleware might be faster? Unsure on that one, it's also slightly cheaper but when we're talking about $0.65 vs $2 it doesn't matter