Improve cache busting (#11846)

This commit is contained in:
Franck Nijhof 2020-01-22 21:05:26 +01:00
parent 528870549a
commit 0f7a8aa73b
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
3 changed files with 13 additions and 3 deletions

10
plugins/cache_buster.rb Normal file
View File

@ -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)

View File

@ -5,7 +5,7 @@ g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script src="/javascripts/prism.js?{{ site.time | date: '%s' }}" type="text/javascript"></script>
<script src="{{ '/javascripts/prism.js' | cache_buster }}" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>

View File

@ -28,8 +28,8 @@
<meta name="twitter:description" content="{{ page.description | default: site.description | strip_html | truncate: 200 }}">
<meta name="twitter:image" content="{{ page.og_image | default: "/images/default-social.png" | prepend: site.url }}">
<link href="/stylesheets/prism.css?{{ site.time | date: '%s' }}" rel="stylesheet">
<link href="/stylesheets/screen.css?{{ site.time | date: '%s' }}" media="screen, projection, print" rel="stylesheet">
<link href="{{ '/stylesheets/prism.css' | cache_buster }}" rel="stylesheet">
<link href="{{ '/stylesheets/screen.css' | cache_buster }}" media="screen, projection, print" rel="stylesheet">
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{ site.title }}" type="application/atom+xml">
<link rel='shortcut icon' href='/images/favicon.ico' />
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />