Knorks Blog: Gotta load fast! Speeding up this blog

submited by
Style Pass
2025-01-04 00:00:07

I’ve been hosting this blog on GitLab Pages for the past eight years or so, and it’s been working great — no real issues. Well, there is one “problem.” The page loading speed isn’t exactly slow . . . but it’s not fast either. Opening the dev tools reveals that the main culprit is latency. GitLab Pages are hosted in the United States, while I’m based across the pond in Germany. This means the round trip to set up a connection (TCP handshake and such) and deliver the initial HTML document takes about 400–600 ms. The HTML document itself contains other files that need to be fetched from the server like style sheets and javascript. These can only be requested once the HTLM document is fully transmitted and parsed1. Once the initial request is fulfilled we can skip the TCP setup however other resources still need to be transmited, parsed and finally rendered. As a result the page is fully rendered in just about a second. That isn’t terrible, but it doesn’t feel fast either. Given that almost no one is reading this blog, it’s probably fine. But I want it to feel fast, so let’s see what can be done.

First, let’s do a sanity check to confirm that latency is actually the issue. For comparison, I set up a virtual machine with Hetzner, which is hosted in Germany. Using Nginx and Let’s Encrypt, I get round-trip times of around 10–15 ms. We can further test this with a VPN. If we connect to an endpoint in the US, there’s minimal overhead when connecting to GitLab Pages directly. However, connecting to the server in Germany incurs significant overhead, as the traffic has to first go through the US endpoint and then back to Germany. Reducing the physical distance between me and the hosting provider seems to be the main culprit.

Leave a Comment