-
More cache busting
I wrote a little bit, a while ago, about my cache busting strategy for this website. The basic idea is to generate a unique identifier at the time of deploy, and then use that unique identifier as a query param for requests to static assets. So that if I haven't deployed in a while, and on the off chance that I have a repeat visitor to this website, that visitor gets the cached version of my (admittedly minimal) CSS and JavaScript. When I re-deploy the website, that visitor's browser will determine that something has changed and reload the files.
Previously, when this website was redeployed using GitHub Actions, I used the ID of the action's run as the unique identifier—on the basis of that identifier being incremented on every deploy.
Now that I deploy manually, I no longer have that identifier. So I use a random hexadecimal string instead:
VERSION=$(openssl rand -hex 4) grep -rl '{|{VERSION}|}' ./templates | xargs sed -i "s/{|{VERSION}|}/$VERSION/g"
This finds all files in my
templates
directory that have the{|{VERSION}|}
string in them (just a distinctive string that I likely won't be using anywhere else)—and then usessed
to replace that string, inline with my random identifier.I suppose I could be doing something clever like hashing each of the files, so the ID doesn't change unless the file does—but this works, and works well for a website of this scale.
Previous
Docker is very good and very powerful and absolutely not what I need in my life right now.
Archive
2024
February 2024
-
Spain: Friday
23Breakfast in Los Montesinos, lunch in Torrevieja, out for a run and then dinner on the coast.
-
Spain: Thursday
22A flight to Alicante, a rental car and a drive through the dark.
-
Replace a sink waste
17 -
2024: the year so far
17
2023
December 2023
-
2023
312023 has been, maybe, my busiest year yet. Stacked to the gills with travel, new experiences, time spent outdoors, time spent in quiet pubs, time spent with Sam & Ghyll out in the wide world.
-
Homeownership
30 -
Poor Charlie's Almanack
29 -
📚
Like, Comment, Subscribe
28
Currently showing latest 20 posts