简体   繁体   English

缓存部分视图Asp.net MVC 5

[英]Caching a Partial View Asp.net MVC 5

I'm calling my partial view using jQuery Load 我正在使用jQuery Load调用我的部分视图

I tried using [OutputCache(Duration = 10, VaryByParam = "*")] but I have the same result I get 200 Ok Instead of 304 not modified 我尝试使用[OutputCache(Duration = 10, VaryByParam = "*")]但我有相同的结果我得到200 Ok而不是304未修改

setInterval(function () {
    $("#ETLjobs").load('@Url.Action("indexp","JobsETL")');
}, 5000);

My controller is 我的控制器是

[DonutOutputCache(Duration = 500)]
public ActionResult Indexp()
{
    var x = db.BIOGetETLJobs();
    var  y = from xx in x
                where xx.etat!="Completed"
                select xx;
    return PartialView(y);
}

by the way how to change the load action to a long polling ?? 顺便说一下如何将加载动作更改为长轮询?

the cashe is working actually i get 200 OK (From Cache) cashe工作实际上我得到200 OK(从缓存)

When using ASP.NET output caching, you will always get a 200 OK, even when the content is served from the server's output cache. 使用ASP.NET输出缓存时,即使从服务器的输出缓存提供内容,也总是可以获得200 OK。 That is the intended behaviour. 这是预期的行为。

The server does not try to determine whether what you have cached locally is older than what is in the server's output cache, thus does not return 304 Not Modified. 服务器不会尝试确定您在本地缓存的内容是否早于服务器的输出缓存中的内容,因此不会返回304 Not Modified。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM