的OutputCache位置=客户端不出现工作 [英] OutputCache Location=Client does not appear to work

查看:163
本文介绍了的OutputCache位置=客户端不出现工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用的OutputCache 属性在我的MVC应用程序,它似乎并没有工作,当我使用 OutputCacheLocation.Client

I am trying to use the OutputCache attribute in my MVC app and it doesn't appear to work when I use 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();
    }        
}

第一个不缓存。我打的页面每一秒它改变的时间。第二个作品。它只是改变了时间每15秒。有我丢失的东西?我调试这个使用IE8和内置的开发服务器在Visual Studio。

The first one does not cache. I hit the page every second and it changes the time. The second one works. It only changes the time every 15 seconds. Is there something I am missing? I'm debugging this using IE8 and the built in development server in Visual Studio.

推荐答案

如果你打<大骨节病> F5 你驱逐客户端缓存。客户端缓存应该是工作的方式是,你必须指向一些其他意见客户端操作,当这些链接在用户点击缓存的版本将在网站上链接获得服务(假设,当然他这样做在该页面缓存的时间间隔)。

If you hit F5 you are evicting the client cache. The way client cache is supposed to work is that you have links on the site pointing to the Client action from some other views and when the user clicks on those links the cached version will get served (assuming of course he does that in the interval for which the page is cached).

这篇关于的OutputCache位置=客户端不出现工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆