Every so often I get a question about Pagecord that I reply to on the socials, or over email. Email is private and I delete old social content, so I thought it might be fun to answer some of these questions in public on my blog now and again. Consider this a pilot episode. Here we go!
Does Pagecord generate the page each time someone visits, or are the pages static?
The honest answer is "a bit of both"!
For blogs on a pagecord.com address (e.g blog.pagecord.com), the page is cached by Cloudflare at the edge for 12 hours. So after the first visit, your readers are served a cached copy from a server near them, and the request never touches Pagecord at all. The only thing that still fires is a tiny analytics ping from the browser, which is how page views keep getting counted even though the page itself is cached. If a customer updates a post, Pagecord tells Cloudflare to refresh that blog's cache.
For blogs using a custom domain, pages aren't edge-cached just yet, so most of those requests do reach the Pagecord server. I have an idea for improving this by letting Cloudflare handle SSL rather than my own server, but it's still on the drawing board and I don't think the lack of edge caching is a big problem for now. The speed of rendering a page including network latency is pretty fast!
In both cases, repeat visits from the same browser are served from the browser's own cache, or get a quick "nothing has changed" (304) response from the app.
What was the driving motivation for pages being dynamic rather than static? I'm old, and I still believe static is the way to go 🤣
If by "static" you mean writing raw HTML files to disk and serving those to readers, then Pagecord doesn't do that because rendering is nuanced, and I want to avoid the pain of a build step.
A blog can be viewed in a lot of ways: a stream of posts, a list of titles, filtered by tag or by language, as a custom home page, RSS, sitemap, and that's before you get into themes and custom CSS! Serving static HTML would require pre-generating every one of these combinations, for every blog. Even the smallest typo fix would result in pre-generating a mountain of files, most of which would never get looked at. Sure, you could work to optimise it, but it would be a lot of unnecessary computation and an expensive bottleneck, resulting in slower publishing. No thanks!
Instead, when you make a change, Pagecord tells Cloudflare to drop the cached copy, and the next visitor gets the fresh version and the cache is updated. Publishing is instant, with no build queue.
So it's essentially "dynamic origin, static edge". In the *.pagecord.com case, the app renders a page once and a CDN serves it statically to everyone after that. For custom domains, each request hits the server, checks a fragment cache (memcached) and pulls the rest of the info from the database which is super-fast.
If you're curious to dive into the depths of this, the Pagecord source code is available on GitHub.
If an occasional AMA post like this is something you'd be keen to see again in the future, please send me your questions via email by clicking the icon below :)

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.