2016-09-23 1 views

답변

5

그 대신 당신이 캐시 설정을 사용하려면 모든 작업 또는 컨트롤러에 설정을 적용해야하는 web.config에서 설정할 수있는 캐싱 프로필 : 당신을위한 옵션을 지정의 Web.config에서

캐시 프로필 :

<system.web> 
    <compilation debug="true" targetFramework="4.5.1" /> 
    <httpRuntime targetFramework="4.5.1" /> 
    <caching> 
     <outputCacheSettings> 
     <outputCacheProfiles> 
      <add name="cp1" duration="30" location="Any" varyByHeader="user-agent" /> 
     </outputCacheProfiles> 
     </outputCacheSettings> 
    </caching> 
    </system.web> 

다음 어디에서나 사용할 수있는 프로필을 사용하고 싶습니다.

[OutputCache(CacheProfile="cp1")] 
public ActionResult Index() { 
    //... 
} 

위의 예는 Apress Pro ASP.NET MVC 5 Platform by Adam Freeman에서 가져온 것입니다. 좋은 읽을 거리로 추천합니다.

+0

제임스 감사합니다, 당신의 대답은 정말 분명합니다. 하지만 캐시 설정을 모든 작업 또는 컨트롤러에 어떻게 적용 할 수 있을지 궁금합니다. 아마 그것은 불필요한 정보는 아니지만 예제를보고 싶습니다. 다시 감사합니다. – Orhun

+0

나는이 블로그 기사 (https://prashantbrall.wordpress.com/2013/09/29/using-output-cache-profile-in-asp-net-mvc/)를 발견했을 것이다. 내 두 번째 질문에 대한 대답. 다시 관심을 가져 주셔서 감사합니다. – Orhun

관련 문제