OutputCache の設定で応答ヘッダがどのように変化するかわからなかったので、いい機会と思ったので調べました。あくまでもヘッダの話なので Cache-Control が no-cache になっているからと言って完全にキャッシュされていないわけではありません。
Duration
| OutputCache | Cache-Control | Pragma | Expires | LastModified |
|---|---|---|---|---|
| Duration = 0 | public, max-age=0 | (なし) | Fri, 01 Apr 2011 12:00:00 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
| Duration = 30 | public, max-age=30 | (なし) | Fri, 01 Apr 2011 12:00:30 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
NoStore
| OutputCache | Cache-Control | Pragma | Expires | LastModified |
|---|---|---|---|---|
| NoStore = true, Duration = 0 | public, no-store, max-age=0 | (なし) | Fri, 01 Apr 2011 12:00:00 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
| NoStore = true, Location = None | no-cache, no-store | no-cache | -1 | (なし) |
Location
| OutputCache | Cache-Control | Pragma | Expires | LastModified |
|---|---|---|---|---|
| Location = Any, Duration = 30 | public, max-age=30 | (なし) | Fri, 01 Apr 2011 12:00:30 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
| Location = Client, Duration = 30 | private, max-age=30 | (なし) | Fri, 01 Apr 2011 12:00:30 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
| Location = Downstream, Duration = 30 | public, max-age=30 | (なし) | Fri, 01 Apr 2011 12:00:30 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
| Location = None, Duration = 30 | no-cache | no-cache | -1 | (なし) |
| Location = Server, Duration = 30 | no-cache | no-cache | -1 | (なし) |
| Location = ServerAndClient, Duration = 30 | private, max-age=30 | (なし) | Fri, 01 Apr 2011 12:00:30 GMT | Fri, 01 Apr 2011 12:00:00 GMT |
ちなみに ASP.NET MVC で全てのアクションでキャッシュを無効にしたいときにはグローバルフィルターを使えばいいです。完全にキャッシュを無効にしたいときには OutputCacheLocation.None を指定します。
public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); filters.Add(new OutputCacheAttribute { Location = OutputCacheLocation.None }); }