.NET MVC OutputCache

Web.config

<system.web>
<!–页面缓存–>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<!–缓存5分钟–>
<add name=”indexindex” duration=”300″ varyByParam=”*” location=”Any”/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>

 

Controller

public class IndexController : Controller
    {
        [OutputCache(CacheProfile = "indexindex")]
        // GET: Home
        public string Index()
        {
            return DateTime.Now.ToString();
        }
    }


发表评论

邮箱地址不会被公开。