When I first started building SaaS products, I thought getting the app to work was the hardest part. I was wrong. The real nightmare started when I tried to add a simple SEO analysis tool. I wrote the logic, tested it on my local machine, and deployed it. It worked fine for me in the US. But when a friend in London tried it, the page took over four seconds to load. I realized my server was physically thousands of miles away from my users. Every request had to travel across the ocean, get processed, and travel back. It felt like ordering a pizza and having it flown in from another country. I was frustrated, my users were waiting, and my server costs were creeping up. So I decided to build something.
The core issue here is something called "latency." In simple terms, latency is the time it takes for data to travel from point A to point B. If your server is in New York and your user is in Sydney, the physical distance alone adds a noticeable delay. When you're building a tool that needs to fetch and analyze a webpage, those extra milliseconds add up. Fetching a page, parsing the HTML, and running checks takes compute time. If all that happens on a single central server, users far away get a sluggish experience. The cost of ignoring this? Users bounce. If a web tool takes more than a couple of seconds to load, people assume it's broken and leave. For a developer, it also means your central server has to work harder, handling long-running connections instead of just quickly responding.
To fix this, I needed to move the processing closer to the user. This is where "edge computing" comes in. Instead of one big server in the US, edge computing uses a global network of smaller servers. When a user makes a request, it's handled by the server geographically closest to them. I integrated Cloudflare Workers into my Next.js setup to handle the heavy lifting at the edge. Workers run JavaScript right on Cloudflare's global network. Let's look at how I built the edge SEO analyzer. Here is the Cloudflare Worker I wrote to handle the requests:
export default { async fetch(request, env) { const url = new URL(request.url); if (url.pathname !== '/api/analyze') { return new Response('Not found', { status: 404 }); } const targetUrl = url.searchParams.get('url'); if (!targetUrl) { return new Response(JSON.stringify({ error: 'Missing url' }), { status: 400, headers: { 'Content-Type': 'application/json' }, }); } // Fetch target page at the edge (low latency worldwide) const response = await fetch(targetUrl, { cf: { cacheTtl: 300, cacheEverything: true }, }); const html = await response.text(); // Run SEO checks (regex-based, no DOM needed) const title = html.match(/<title[^>]*>([^<]*)<\/title>/i)?.[1] || ''; const desc = html.match(/<meta[^>]*name=["']description["'][^>]*content=["']([^"']*)["']/i)?.[1] || ''; const h1Count = (html.match(/<h1[ >]/gi) || []).length; return new Response(JSON.stringify({ title, desc, h1Count }), { headers: { 'Content-Type': 'application/json' }, }); }, }; Let's break this down for beginners. First, we check the URL path to make sure it's the right endpoint. Then, we grab the url the user wants to analyze. The magic happens in the fetch call. Notice the cf object? That's a Cloudflare-specific setting. By setting cacheTtl (Time to Live) and cacheEverything, we tell the edge server to temporarily save the fetched HTML. For example, if we set the TTL to 300 seconds, and another user in the same region asks for the same site five minutes later, we don't have to fetch it from the origin again; we just serve it from the edge cache. This saves massive amounts of time. Finally, we use some simple regular expressions to extract the title, description, and count the H1 tags. I used regex instead of a heavy DOM parser because it keeps the worker lightweight and fast. Because this runs at the edge, a user in Tokyo gets the result from a Tokyo server, not a Virginia one.
The difference was immediate. For example, load times for international users dropped from several seconds to a fraction of a second. What surprised me the most was how little code it actually took. I was worried edge computing would require learning a completely new framework or dealing with complex infrastructure. But because Cloudflare Workers use standard JavaScript and the Fetch API, the learning curve was surprisingly gentle. It felt just like writing normal backend code. If I were to do it again, I would probably implement more aggressive caching strategies right from day one. I initially set the cache TTL to just 5 minutes, but for static SEO checks, caching for an hour or more would save even more compute cycles and make the tool feel instantaneous for repeat checks. I also had to adjust how I handled environment variables, as edge environments have slightly different ways of managing secrets compared to traditional Node.js servers.
Building this edge-powered SEO checker was such a fun learning experience that I ended up packaging it into a free tool for anyone to use. If you want to test your own site's basic SEO metrics without any latency, you can try it out here: SEO Checker. It runs entirely on the edge, so it's fast no matter where you are in the world. I also used this exact architecture to build SaaSLaunch, a Next.js and Stripe boilerplate, but the free tool is a great way to see the edge computing concepts in action without writing any code.
Full disclosure: I'm the developer of SaaSLaunch. I built this because I needed it myself.
