Web HTTP - Cache Bursting

> (World Wide) Web - (W3|WWW) > (HTTP|HTTPS) - Hypertext Transfer Protocol

1 - About

A cache-buster makes the URL unique each time the content is new.

Because the cache key of the resources contains the URI, the HTTP cache mechanism (of the browser, proxy,…) will have then a cache miss and will be then forced to fetch the resources again.

The cache-buster can take the form of

  • a unique query string used uniquely to form a unique URL
  • or an unique location path:
    • with the version in the path or in the name of the file
    • or with http rewrite
Advertising

3 - Syntax

my.js?ver=3.0.1
<!-- or -->
my-3.0.1.js <!-- with http rewrite rule to redirect to the file my.js -->

4 - Implementation

  • Manually add a cache buster when the file has changed
  • Automatically compute it for instance to Hash or Date Time value.