Skip to content

Instantly share code, notes, and snippets.

@manikrathee
Forked from daneden/.htaccess
Created October 28, 2013 02:23
Show Gist options
  • Save manikrathee/7190490 to your computer and use it in GitHub Desktop.
Save manikrathee/7190490 to your computer and use it in GitHub Desktop.
Cache Buster for Jekyll - Forked from Dan Eden
RewriteRule (.+)-[a-zA-Z0-9]+(\.(js|css))$ $1$2 [L]
# /_plugins/cachebuster.rb
require 'digest/sha1'
module Jekyll
class CacheBuster < Liquid::Tag
def render(context)
"#{Digest::SHA1.hexdigest(Time.now.to_s)}"
end
end
end
Liquid::Template.register_tag('bust_cache', Jekyll::CacheBuster)
<!-- /_layouts/default.html -->
<html lang="en">
<head>
<!-- ... -->
<link rel="stylesheet" href="/assets/css/style-{% bust_cache %}.css">
<!-- E.G. Outputs <link rel="stylesheet" href="/assets/css/style-afdebe725f30fd53978fabf045308bd1127b3a95.css"> -->
<script src="/assets/js/app-{% bust_cache %}.js"></script>
<!-- ... -->
</head>
<body>
<!-- ... -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment