Fri, 28th November 2025
Today's post is about two things I think would make HTML better: cache busting and templating!
I have no influence whatsoever over these things, so I guess this post it just a "fun to think about" proposal.
I think it's also best if I go through them one at a time, so let's do that.
AI disclaimer: I wrote this post myself, this is all my writing. But I did go to ChatGPT with these ideas and got some great help/discussion with the details and example HTML!
So, you've just updated your stylesheet. You go check your site, and wut? It looks the same! This is because your browser has "cached" or stored the stylesheet, and when you visited the site after updating your stylesheet, your browser used the cached/stored version for faster performance (rather than loading it again from the website).
You can force the browser to get the latest version of a stylesheet with a URL parameter. That is, if you change your href="stylesheet.css" to href="stylesheet.css?v=2", the browser sees it as a new, different URL and fetches it a-fresh.
Problem solved right? Well, yes and no.
If you have a website with multiple pages, you'll need to add the ?v=2 to every single page which uses the stylesheet. For large sites, that's a lot of work, or at the very least, a big find-replace, and then you have to re-upload every single file.
So here's my proposal. What if we just had a cachebust.txt, or a version.txt as a file on the site. That file would contain your version number (equivalent to the ?v=2 above). And browsers checked for it. If it existed, the browser would automatically request stylesheets, scripts and other assets using this number. Now you only have one simple file to update, and don't need to re-upload your entire site.
So many static sites, like mine have the same layout on every page, and then there is some unique content on that page. Now, let's say I want to make a change to the layout's HTML, e.g. add a new page link to the main menu. On most sites, I would have to go through every single page and make the change, and then upload every single affected page.
Fortunately, I've gotten around this using some JavaScript tricks. I have achieved "templating" where my layout.html is separate from my page's unique content. The JS merges them together depending on which page you're on and delivers the final page.
Other solutions include using Static Site Generator to generate and upload your site, use PHP or other server-side code for templating.
Once again, what if this wasn't necessary? What if HTML had templating built in and you didn't need an extra build step, or server-side code, or JavaScript tricks?
To summarise, your site's files would include a layout.html (or maybe template.html), and then other pages would specify they want to use that template.
<!DOCTYPE html>
<html>
<head>
<title>[page_title]</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>My Site</header>
<main>
[page_content]
</main>
<footer>© 2025</footer>
</body>
</html>
<!DOCTYPE html>
<head>
<title>About | Someone's Website</title>
<use-template src="layout.html">
</head>
<body>
<p>This is the about page content.</p>
</body>
Then, when the visitor requests about.html, the browser would see the use-template tag in the header. Load that in, then swap [page_title] for about.html's title, and [page_content] for about.html's contents, resulting in the final page, who's code will look like this:
<!DOCTYPE html>
<html>
<head>
<title>About | Someone's Website</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>My Site</header>
<main>
<p>This is the about page content.</p>
</main>
<footer>© 2025</footer>
</body>
</html>
And that's it! My two wishes for HTML. I hope you enjoyed!