Versioning Static Assets w/ Heroku Config Vars
17 Oct 2012Cache-related HTTP headers are a great tool in our web dev toolbox, but some browsers still find ways to ignore them, requiring us to fallback to our old methods of static versioning.
Here is a quick and easy way of managing your static versions using Heroku’s config vars. This example uses Django, but the idea can be applied to any backend.
1) Create a template context processor like this:
2) Add it to your TEMPLATE_CONTEXT_PROCESSORS
3) Apply the template variables to your link/script tags:
4) After pushing out your code, setup your config vars:
So from now on, when you make some changes to your static content and push it out to Heroku, you can easily version them by incrementing the value of your static version config vars.