3 years ago

For cache-busting static file served by Cloudfront, we're using incrementing version numbers for both CSS (style.css?v=4) and Javascript (app.js?v=10). Incremental version numbers aren't ideal, but they work as a stop-gap method for non-critical deployments or as a temporary measure.

For this particular project, the backend web server is deployed on Heroku, and the frontend JS/CSS is on a static hosting server set as Cloudfront's origin. Every time we deploy a new frontend app version, we increment an environmental variable on Heroku, which then starts returning the new version number for each asset in the HTML.

Our deployment is handled via Grunt, and runs the following bash command:

heroku config:set CSS_VERSION=$((`heroku config:get CSS_VERSION` + 1))  

This retrieves the current CSS_VERSION from the Heroku app, increments it, and runs a Heroku config:set command to set the new value and restart the app.