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

How to Serve Outlook File Type on IIS

If you need to have Outlook File Template (.oft) to open via a click on a landing page, be aware that .oft is not part of the default mime types and it has to be manually added. If you try to open an OFT link with default settings, you will be getting a 404 error.

IIS 404 Error Message

You can add the Mime Type via IIS Manager or directly editing the web.config file in root directory.

Adding MIME Type from IIS Manager

  1. On IIS, click on the site application on the left pane and double-click on the MIME Types icon.

    MIME Types Settings Icon on IIS

  2. On the right pane, click Add… and type in the extension for File name extension: and the application type under MIME type:. In this case, you want to type in “.oft” and “application/vnd.ms-outlook” (without quotes) respectively.

    MIME Types Settings on IIS

  3. Click OK and restart IIS.

Adding MIME Type Directly to web.config

The second way to add a MIME type is by directly modifying the web.config file under your root directory. Adding one line on top of the web.config from the ETags configuration example, we just need to add one line as highlighted in example below:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".oft" mimeType="application/vnd.ms-outlook" />
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" setEtag="false" />
  </staticContent>
</system.webServer>

Typically you want to also include Outlook MSG File (.msg) in your MIME Types. In this case, you just need to add another line in your web.config file like so:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".oft" mimeType="application/vnd.ms-outlook" />
    <mimeMap fileExtension=".msg" mimeType="application/vnd.ms-outlook" />
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" setEtag="false" />
  </staticContent>
</system.webServer>

Keep in mind, even if you add MIME types with IIS Manager, it will modify the web.config so you only need to choose either one, not both.

Further Reading

How do I open Outlook Template Files in the client application from a document library?
Opening .msg e-mails in Outlook from a SharePoint 2010 document library.
MIME Types
How to Serve AVIF Image on IIS
How to Serve WebP image on IIS

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

How to Disable ETag Header on IIS 8.5 Web Application

If you analyze a classic ASP or ASP.NET web application using YSlow, you’ll notice that more often than not (if not always), you’ll get an F grade on the Configure entity tags (ETags).

YSlow misconfigured ETags

In general, you can ignore this if you’re using IIS 7 or later as it’s not affecting much of IIS performance tuning. However, if you’re nitpicky about the test result, this can be fixed easily.

The easiest fixed to do is to remove the ETag header from the HTTP response on IIS. And here’s how you can do that easily just by tweaking the web.config file under the application root directory.

<configuration>
  ...
  <system.webServer>
    ...
    <staticContent>
      <clientCache setEtag="false"/>
    </staticContent>
    ...
  </system.webServer>
  ...
</configuration>

Sometimes you’ve already had an entry for clientCache, then you can just add in the setEtag attribute within the element like so:

<staticContent>
  <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" setEtag="false" />
</staticContent>

Clear your browser’s cache and run YSlow test again, and this time you should see grade B or better on the Configure entity tags (ETags) section on the YSlow result.

YSlow configured ETags

Caveat

This solution works at the application level so it may not be practical, so it has to be done for each application you want to have Etag disabled. If you have more than a dozen applications on the server. In which case, you want to implement a solution targeted at the server level instead (using URL Rewrite).

Further Reading

Professional Microsoft IIS 8
Configure ETags
Client Cache

February 28, 2015 Filed Under: How To Tagged With: Etag, IIS, Internet Information Services, Microsoft, Windows Server

How to Install SMTP Server on Windows Server 2012 R2

The internal SMTP server feature is deprecated but not removed on Microsoft Windows Server 2012, so when moving legacy applications from an older server, you can still install the internal SMTP under IIS 6 on Windows Server 2012 R2 to avoid using a separate Exchange Server. Here are the steps to install it.

Steps

  1. Launch Server Manager.

  2. On the Dashboard, click Add roles and features on the right pane.

    Server Manager Dashboard on Windows Server 2012 R2

  3. Click Next > button to go to Installation Type (on left) and select Role-based or feature-based installation on the right and click Features on the left.

  4. In a box under the heading Features, check SMTP Server. There will be a pop-out screen to add more services or features. Just click the Add Features button.

    Add SMTP features on Windows Server 2012 R2

    Add features required for SMTP on Windows Server 2012 R2

  5. You will be shown a confirmation screen. Click the Install button. Click Close button when finished.

  6. You can find the IIS 6 by going to the tile menu and pick the icon with the purple background as pictured.

    IIS 6 on Windows Server 2012 R2

  7. Launch the IIS 6 Manager to configure the SMTP server.

    IIS 6 Manager on Windows Server 2012 R2

The default location of your SMTP folders will be in C:\inetpub\mailroot. You can move these default directories to a different drive.

Further Reading

Features Removed or Deprecated in Windows Server 2012 R2
How to Fix SMTP 550 5.7.1 Unable to Relay Error on Windows Server 2012 R2
Mastering Windows Server 2012 R2
Windows Server 2012 R2 Inside Out Volume 1: Configuration, Storage, & Essentials
Windows Server 2012 R2 Inside Out Volume 2: Services, Security, & Infrastructure
Training Guide Installing and Configuring Windows Server 2012 R2 (MCSA)

January 14, 2015 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, Simple Mail Transfer Protocol, Smtp Server, Windows Server

How to Find Windows 8 or Windows 8.1 Key

As part of windows 8 upgrade to 8.1, if you do a fresh install of Microsoft Windows 8.1 using Windows 8 key, one issue you may run into is you may not have your Windows 8 product key handy. If you still have your old system running, you might be able to extract your Windows 8 (or 8.1) key from the registry by using a key finder software, so you should do this step first before installing 8.1 over the existing Windows 8.

There are many key finder software available, but I find Belarc Advisor (not affiliated) to work very well for this purpose. The program will create a detailed profile of your PC, including installed software, and save it in an HTML file to your local hard drive. Once profiling is complete, the HTML will automatically open in your browser. Click on Software Licenses on the left of the page to see your software.

Belarc Advisor Overview

On Software Licenses section, you should see most of your installed software listed along with the product keys. Not all product keys will be displayed, fortunately, Windows 8 product key is among the listed.

Belarc Advisor Software Licenses

Write down the Windows 8 product key and save it for your Windows 8.1 activation after installing it using KMS Key.

As you might have figured this out, this trick works not only for a windows upgrade, but you can also use this to reinstall windows 8.1 (or 8) without the serial number handy.

The FREE version (for personal use only) of Belarc Advisor is more than sufficient for this task and rest assured it does not send up your PC profile to a Web server across the Internet.

This solution does not always work, but I’ve seen good results in most cases. So I think it’s worth a try before you do anything more involved.

Download

Belarc Advisor – Free Personal PC Audit software.

May 21, 2014 Filed Under: How To Tagged With: Microsoft, Windows 8

« Previous Page
Next Page »
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