CDNs, browser caching and cache invalidation

ConfigBox's static assets as well as static content from product data can be served with far future headers and cache invalidation can be handled with the application.

Cache invalidation

  • Application assets: each application asset (stylesheets, JavaScript, images) have a cache-busting query string. The value changes with each release version.

  • Assets from product data: Changes to static assets (product images etc) trigger a rename of the uploaded file.

  • Assets from customizations: Implemented by way of cache-busting. Developers need to implement a specific function (see below at 'Implementing cache busting for customization assets'

Set suitable cache headers for static content

Apache

.htaccess files are placed where needed out of the box. These set Cache-Control to 'public' and end Expires to 1 year ahead from access time.

Be sure to have the modulesĀ mod_headersĀ andĀ mod_expiresĀ enabled.

nginx

Set cache headers for these locations

Implementing cache busting for customization assets

  • Create a PHP file inĀ {customization folder}/system_overrides/releaseNumber.php (or pick any other file name)

  • Add a function called getReleaseNumber(), have it return a string of your choosing

  • Change it whenever you need to invalidate your static assets.