Cache Busting

Photo Credit: Doug Kline

Cache Busting

Introduction

Caching busting stops browsers from using a cached file when an new updated version is available.

If you are following best practices for caching your assets (Google - Optimize Caching) you might find that browsers will used the cached version of a file even when a new updated version is available.

This issue becomes worse when proxies, load balancers and other helpful machines are taken into consideration.

To get around problem you need to cache bust meaning that the browser and anything in between knows to request the latest version of the file. There are a number of ways this can be done, best practice is to rename the whole file by appending a version number, date/time or hash to the end of the file name.

This process can be done a number of ways including: Build process, Grunt or Web server configuration.

Summary

  • Browsers, proxies and other servers can cache files even when they have changed.
  • Giving a file a unique filename will help break any caching occurring on file updates.
  • Renaming the file is better than adding a query string.
  • Multiple ways of automating this process. Build Process, Grunt, Web Server configuration.

Further Reading