How to add a browser cache busting mechanism to WorkflowGen

Adding a cache busting mechanism to WorkflowGen is useful because it eliminates the need to clear the browser cache after upgrades to see the most recent updates. Developers can make these updates available to end-users immediately without having to clear their caches.

Note: WorkflowGen v8 has already some built-in cache busting capabilities. If some files are still loaded from your browser cache, you can use the solution below for those specific files.

To add a cache busting mechanism:

  1. Download and install URL Rewrite on the WorkflowGen IIS web server.

  2. Create a new web.config file with the following contents and add it to the wfgen folder’s parent folder (e.g. \inetpub\wwroot), replacing the version number in the value attribute of the <action> tag (v=X.X.X) with your version number of WorkflowGen (this example uses v=7.1.0 for version 7.1.0), or you can use your own business versioning rules.

    Notes

    • Whenever you upgrade WorkflowGen, you’ll have to replace X.X.X with the new version number, or your own business versioning rules.

    • You can add other pages or file types in the <match>.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
              <outboundRules>
                <rule name="Cache buster HTML" preCondition="IsHTML">
                  <match filterByTags="A, Img, Link, Script" pattern="^.+\.(css|js|png|jpg|svg)$" />
                  <action type="Rewrite" value="{R:0}?v=7.1.0" />
                </rule>
                <preConditions>
                  <preCondition name="IsHTML">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                  </preCondition>
                </preConditions>
              </outboundRules>
            </rewrite>
        </system.webServer>
    </configuration>
    

Reference to the original solution: GitHub - JeevanJames/CacheBustingWithIISRewrite: Demonstrates cache busting with IIS rewrite outbound rules