Browser Cache Buster
Elency Solutions, Lee Crowe
This is done by renaming assets to include an MD5 hash of the asset file content and updating all relevant source files within the web site code base.
Firstly you will need to download the BrowserCacheBuster.exe and it’s dependent assemblies from codeplex. The executable is a windows executable and requires .Net framework v4.0 to be installed on the executing machine.
When running the BrowserCacheBuster application without any arguments you will be shown all of the available arguments that can be passed in as shown in the image below.
When running the cache buster there are a number of required and non required arguments. There are also two command types.
Get Unique asset and source file extensions
The command below will allow you to see all of the unique file extensions within the defined asset and source folders:
BrowserCacheBusting.exe -c:1 -afp:c:\dev\web\assets -srfp:c:\dev\web -sfp:c:\dev\web
This can be useful to understand which file extensions should be included/excluded.
There are many command line arguments available but all of the arguments can also be defined in the application configuration file BrowserCacheBustiner.exe.config. If defined these would become the application defaults but can be overridden via the command line arguments.
When Cache Busting you will need to supply all of the required arguments. But you can also supply various filters for file paths, file names and file extensions which can be used to include/exclude files and directories.
The command below will hash all asset files which have the following extensions .js,.css,.jpg and .png. It will also update all source files excluding files with a .jpg or .png extension.. The arguments are also telling the cache buster to delete the old versions of asset files.
BrowserCacheBusting.exe -c:0 -afp:c:\dev\web\assets -sfp:c:\dev\web -srfp:c:\dev\web -afef:.js,.css,.jpg,.png -afeft:1 -sfef:.jpg,.png -sfeft:0 -d:1
The screen dump of the executed command is below:
Other Useful Information