Created
February 20, 2014 07:32
-
-
Save yuchant/9108622 to your computer and use it in GitHub Desktop.
very simple git revision based cache buster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# very simple git revision based cache buster | |
app = make_app() | |
def get_git_revision_hash(): | |
''' | |
Get current revision short hash and use as cache buster key. | |
''' | |
import subprocess | |
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']) | |
git_revision_hash = get_git_revision_hash() | |
STATIC_ENDPOINTS = [ | |
'static', | |
'shop.static', | |
] | |
@app.url_defaults | |
def static_cache_buster(endpoint, values): | |
if endpoint in STATIC_ENDPOINTS: | |
values['_v'] = git_revision_hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment