OutputCache Location =客户端似乎不起作用

Dis*_*ile 16 c# asp.net-mvc outputcache

我试图OutputCache在我的MVC应用程序中使用该属性,它在我使用时似乎不起作用OutputCacheLocation.Client:

public class HomeController : Controller
{
    [OutputCache(Duration=15, Location=OutputCacheLocation.Client)]
    public ActionResult Client()
    {
        ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss");

        return View();
    } 

    [OutputCache(Duration=15, Location=OutputCacheLocation.Any)]
    public ActionResult Any()
    {
        ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss");

        return View();
    }        
}
Run Code Online (Sandbox Code Playgroud)

第一个不缓存.我每秒都会点击页面,它会改变时间.第二个工作.它只会每15秒更改一次.有什么我想念的吗?我正在使用IE8和Visual Studio中的内置开发服务器进行调试.

Dar*_*rov 18

如果你遇到了F5你正在驱逐客户端缓存.客户端缓存应该起作用的方式是,您在网站上有链接指向Client来自其他一些视图的操作,当用户点击这些链接时,缓存版本将被提供服务(当然,假设他在该时间间隔内执行此操作)页面被缓存).

  • @Dismissile,我认为这种行为略有不同浏览器,但是,通常只输入地址将尊重缓存,F5将暂时忽略缓存*或*逐出缓存资源. (2认同)