Skip to content

Instantly share code, notes, and snippets.

@yuchant
Created February 20, 2014 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuchant/9108622 to your computer and use it in GitHub Desktop.
Save yuchant/9108622 to your computer and use it in GitHub Desktop.
very simple git revision based cache buster
# 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