Cache busting of CSS/JS

I wrote a small Go program to generate the sequence numbers, based on system time. See https://bitbucket.org/rickb777/timestamp

Then I run a shell script: make-config.sh

#!/bin/bash -e
cd $(dirname $0)
OUT=${1:-data/build.yaml}

timestamp=$(timestamp -base 36 -precision min -zero 2015-07-01)
echo "timestamp=$timestamp" | tee timestamp.cfg

mkdir -p $(dirname $OUT)
echo "timestamp: $timestamp" > $OUT

Then I use .Site.Data.build.timestamp in my template partials, e.g.

This presumes there is a directory with name starting with a and containing the timestamp. This is achieved by putting the static files that are ‘far-future’ into static/a and making a symlink like this:

. timestamp.cfg
cd htdocs
ln -sv a a$timestamp

(which is also done in a script).

1 Like