[英]Can I make it so the uesr's browser will cache an MVC3 page?
I have pages that stay the same from week to week.我的页面每周都保持不变。 Every time a user requests them they are regenerated again.
每次用户请求它们时,它们都会重新生成。
I have set up the following for static:我为 static 设置了以下内容:
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
</system.webServer>
Is there something that I can do to make the dynamic pages also cache?我可以做些什么来使动态页面也缓存吗?
This is not set on your pages (Views) but on your Actions.这不是在您的页面(视图)上设置的,而是在您的操作上设置的。
There is an OutputCache ActionFilter you can use:您可以使用一个OutputCache ActionFilter :
public class HomeController : Controller
{
[OutputCache(Duration=10, VaryByParam="none")]
public ActionResult Index()
{
return View();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.