Skip to content

Instantly share code, notes, and snippets.

@Andy-set-studio
Created June 11, 2019 19:43
Show Gist options
  • Save Andy-set-studio/2d718383090cf4c04edfb4e44906288d to your computer and use it in GitHub Desktop.
Save Andy-set-studio/2d718383090cf4c04edfb4e44906288d to your computer and use it in GitHub Desktop.
Cache busting with 11ty (stick global.js in _data folder)
module.exports = {
random() {
const segment = () => {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return `${segment()}-${segment()}-${segment()}`;
}
};
<link rel="stylesheet" href="/css/main.js?v={{ global.random() }}" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment