1

@OutputCacheディレクティブを使用する場合、web.configで次のようにキャッシュプロファイルを定義できます。

<system.web>
  <caching>
    <outputCacheSettings>
      <outputCacheProfiles>
        <add name="myprofile" duration="30" enabled="true" varyByParam="myfield"/>
      </outputCacheProfiles>
    </outputCacheSettings>
  </caching>
</system.web>

ただし、私のアプリには、宣言型の代わりにプログラムによるキャッシュを使用する必要があるページがいくつかあります。例:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);

Response.Cacheを使用してoutputCacheProfilesを活用することは可能ですか?例えば、

Response.Cache.ApplyCacheProfile("myprofile");
4

2 に答える 2

0

MVCでは、コントローラーで属性を使用できます[OutputCache(CacheProfile = "myprofile")]

于 2013-10-18T08:08:36.200 に答える
0

キャッシュ可能性プロパティは location と呼ばれるため、プログラムで設定する必要はありません。

于 2010-12-23T16:14:05.287 に答える