IIS または IIS Express を使用している場合、最も簡単な解決策は、web.config
ファイルに設定を追加して、開発環境でキャッシュを完全に無効にすることです。
注:web.config
ファイルがない場合は、Web サイトのルート ディレクトリに作成できます。
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
または、Web サイトの特定の場所にあるファイルのキャッシュを無効にすることもできます。
<configuration>
<location path="path/to/the/file">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>
いずれの場合も、テスト/実稼働環境でこれらのセクションを削除するために、リリース中にWeb 構成変換を使用できます。
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- Use this section if you are disabling caching site-wide -->
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" xdt:Transform="Remove" xdt:Locator="Match(name)" />
</customHeaders>
</httpProtocol>
</system.webServer>
<!-- Use this section if you are disabling per folder (duplicate if necessary) -->
<location path="path/to/the/file" xdt:Transform="Remove" xdt:Locator="Match(path)">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>
参照: weserver 構成設定を使用して IIS 7 で個々のファイルのキャッシュを無効にする方法