Disabling browser caching for specific folders or files

Overview

Administrators can configure their site to disable browser caching for specific folders or files. This is useful in cases where users report that the site is serving them old versions of content unless they clear their browser cache.

Step-by-Step Guide

Use the following procedures to disable caching of a specified file or folder.

Disable caching for a file

  1. Access your site's web.config file.
  2. Add the following elements to the config file, between the <configuration> and </configuration> tags. These elements include a location element that specifies the path to the file for which you are disabling browser caching. In the example below, the file "publication.pdf" from the root folder will not be cached.

    <location path="publication.pdf">
         <system.webServer>
              <staticContent>
                   <clientCache cacheControlMode="DisableCache" />
              </staticContent>
         </system.webServer>
    </location>
  3. Upload a new version of the file to that folder and confirm that users are served the new file rather than a cached version.

Disable caching for a folder

  1. Open your preferred text editor.
  2. Create a new file with the following text and save it as web.config:

    <?xml version="1.0" encoding="UTF-8" ?>
    <configuration>
         <system.webServer>
              <staticContent>
                   <clientCache cacheControlMode="DisableCache" />
              </staticContent>
         </system.webServer>
    </configuration>
  3. Move the newly created web.config file to a folder on your DNN site server to disable browser caching for that folder and its contents. For example, placing the file in the Assets folder on your server would prevent browsers from caching any of the files in that folder or its subfolders. If the folder already has a web.config file, edit the existing file to include <clientCache cacheControlMode="DisableCache" /> within the staticContent element.
  4. Upload new versions of files to that folder and confirm that users are served new files rather than cached versions.

Comments

0 comments

Please sign in to leave a comment.