From a52c915a31db041268389fa3dac0b2b3366227bb Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 22 Jan 2020 21:05:26 +0100 Subject: [PATCH] Improve cache busting (#11846) --- plugins/cache_buster.rb | 10 ++++++++++ source/_includes/javascripts/scripts.html | 2 +- source/_includes/site/head.html | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 plugins/cache_buster.rb diff --git a/plugins/cache_buster.rb b/plugins/cache_buster.rb new file mode 100644 index 00000000000..895b39a2eeb --- /dev/null +++ b/plugins/cache_buster.rb @@ -0,0 +1,10 @@ +module Jekyll + module CacheBuster + require 'digest/md5' + def cache_buster(file_name) + [file_name, '?', Digest::MD5.hexdigest(File.read(File.join('./source', file_name)))].join + end + end +end + +Liquid::Template.register_filter(Jekyll::CacheBuster) diff --git a/source/_includes/javascripts/scripts.html b/source/_includes/javascripts/scripts.html index 4330401c789..79868bc88da 100644 --- a/source/_includes/javascripts/scripts.html +++ b/source/_includes/javascripts/scripts.html @@ -5,7 +5,7 @@ g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js s.parentNode.insertBefore(g,s)}(document,'script')); - + diff --git a/source/_includes/site/head.html b/source/_includes/site/head.html index 35b140ccf88..b965a92e387 100644 --- a/source/_includes/site/head.html +++ b/source/_includes/site/head.html @@ -28,8 +28,8 @@ - - + +