IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

Disable Browser Caching for Specific Files on IIS

As part of IIS performance tuning in improving a website load speed, in general you want to enable browser caching by double-clicking on HTTP Response Headers in IIS Manager and check the Expire Web content: and set the After: with an x number of days.

IIS HTTP Response Headers to Cache Static Files

By enabling this feature, IIS basically tells the browser to cache all static contents from the web server to the browser so on subsequent page load, the browser does not need to request all the static contents from the server as long as the cache hasn’t expired. This caching feature can also be fine-tuned for specific files or directories on the web application.

Occasionally though you want to disable the browser to cache specific files that may get updated often. For the sake of this example, we have a file myimage.png that shouldn’t be cached by the browser.

In order to do this, we can disable static file caching in web.config by having the following configuration:

<configuration>
  ...
  <location path="myimage.jpg">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="DisableCache" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>

As you can see from the configuration staticContent element, this method only works for static content.

Make sure after doing all this you reload the page while clearing the cache in your browser by pressing CTRL-F5 on Windows or SHIFT-COMMAND-R (⇧⌘R) on macOS.

Further Reading

How to Cache Specific Static Files and Directories on IIS
Ultra-Fast ASP.NET 4.5 (Expert’s Voice in ASP.Net)
Professional Microsoft IIS 8

March 9, 2015 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, Windows Server

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure