1. Background

    What we mean by “cache-busting” is the usage of query strings, in order to have one file producing different outputs, which will be separately cached and considered unique content.

    As an example, the PHP image resizing script “TimThumb” has the ability to provide different image sizes from a single origin file, by using different query strings. For another example, lets say you have a CSS file that defines a background image for a certain box in HTML and you want to use the same CSS for different boxes:

    style.css

    body
              {
              background-image:url(‘back.png’);
              background-color:#cccccc;
              }

    style.css?back=2

    body
              {
              background-image:url(‘back-2.png’);
              background-color:#cccccc;
              }

    style.css?back=3

    body
              {
              background-image:url(‘back-3.png’);
              background-color:#cccccc;
              }
  2. First thing you need to do is enable the Query String option inside the zone’s settings in the Control Panel. This option will force the CDN to honor query strings and treat them as separate items (files).
  3. Next, to cache all three versions of this file you need to initiate a CDN request that will be passed through to origin end and fetch it to CDN:
    • http://foo.bar.netdna-cdn.com/style.css
    • http://foo.bar.netdna-cdn.com/style.css?back=2
    • http://foo.bar.netdna-cdn.com/style.css?back=3
  4. Since Query String is enabled, even though there is only one file, the output will be different and CDN will treat these as separate files.
  5. Origin Swapping
    This feature can be expanded in a way that you can change origin source for each version of cached files from domain.com to different-domain.com:

    1. Edit the Origin URL.
    2. Purge the file (for example “style.css?back=2”).
    3. Request the file (for example “style.css?back=2”) from this zone by loading it in a browser or running curl -I http://foo.bar.netdna-cdn.com/style.css?back=2
  6. After this last step you will have “style.css?back=2” cached from different-domain.com and style.css, file.css?back=3 cached from domain.com.
    Correspondingly, when Query String is disabled, purging any file.css* variants will result in purging the main file.css file as if the Query String was never honored. By using these strings, you will be able to edit the main file on the origin server, while not affecting the cached version.