是什么让缓存从WebMatrix的工作吗? [英] What keeps caching from working in WebMatrix?

查看:111
本文介绍了是什么让缓存从WebMatrix的工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些,我已经添加了code的一行在WebMatrix的剃刀ASP.Net网站页面:

  Response.OutputCache(600);

从阅读它,我曾以为,这是不是意味着IIS将创建的页面生成的HTML的高速缓存,服务于该HTML在接下来的10分钟和10分钟后,当一个请求进来了,它会运行再次code。

现在的页面被取出作为计时的jQuery调用的一部分。在客户端的时间code运行的每一分钟。在code也很简单:

 函数wknTimer4(){
        $获得('PerfPanel'功能(数据){
        $('#perfPanel')的html(数据);        });

它,偶尔会出现缓存,但是当我看到在这10分钟内完成数据库查询的次数,我可能有超过100个数据库查询。我知道缓存不工作我所期望的方式。是否缓存只针对单一会话工作?有一些其他限制?

更新:它真的并不重要客户做什么,无论它通过一个jQuery调用,或直HTML抓取网页的内容。如果服务器的缓存,它并不重要客户做什么。

更新2:完全code倾倒在这里。无聊的东西:

  @ {    变种DB = Database.Open(LOS);
    VAR selectQueryString =SELECT * FROM LXD_funding ORDER BY LXDOrder
    //缓存页面结果600秒
    Response.OutputCache(600);
 }@foreach(在db.Query(selectQueryString)VAR行){    < H1>
    &所述; A HREF =Dashboard/FundingDetails/@row.Status> @ row.quotes&下; / A>贷款@ row.NALStatus,最古老的@(NALWorkTime.WorkDays(row.StatusChange,DateTime.Now))天    < / H1>}


解决方案

您如何的OutputCache作品是正确的假设。你可以检查萤火虫或Chrome工具看打你的网页的传出请求?如果你正在使用jQuery,有时人们设置的$不用彷徨或$就为false,这将导致请求的页面有一个时髦的尾部查询字符串缓存属性。我做了设置此功能在全球范围内解决与jQuery和IE浏览器的一些问题的错误:

http://api.jquery.com/jQuery.ajaxSetup/

另外看看这里是DB调用的分组。你只是做了很多一个请求调用的?你是在一个循环中执行DB命令,另一位读者之内?在这种情况下,code将是有益的。

祝你好运,我希望这有助于!

I have a number of pages in a WebMatrix Razor ASP.Net site where I have added one line of code:

    Response.OutputCache(600); 

From reading about it I had assumed that this mean that IIS would create a cache of the html produced by the page, serve that html for the next 10 minutes, and after 10 minutes when the next request came in, it would run the code again.

Now the page is being fetched as part of an timed jquery call. The time code in the client runs every minute. The code there is very simple:

        function wknTimer4() {
        $.get('PerfPanel', function(data) {
        $('#perfPanel').html(data);

        });

It occasionally appears to cache, but when i look at the number of database queries done during the 10 minute period, i might have well over 100 database queries. I know the caching isn't working the way I expect. Does the cache only work for a single session? Is there some other limitation?

Update: it really shouldn't matter what the client does, whether it fetches the page through a jQuery call, or straight html. If the server is caching, it doesn't matter what the client does.

Update 2: complete code dumped here. Boring stuff:

@{  

    var db = Database.Open("LOS"); 
    var selectQueryString = "SELECT * FROM LXD_funding ORDER BY LXDOrder"; 
    // cache the results of this page for 600 seconds
    Response.OutputCache(600); 


 }



@foreach (var row in db.Query(selectQueryString) ){

    <h1>
    <a href="Dashboard/FundingDetails/@row.Status">@row.quotes</a>  Loans @row.NALStatus, oldest     @(NALWorkTime.WorkDays(row.StatusChange,DateTime.Now)) days

    </h1>

}

解决方案

Your assumptions about how OutputCache works are correct. Can you check firebug or chrome tools to look at the outgoing requests hitting your page? If you're using jQuery, sometimes people set the cache property on the $.get or $.ajax to false, which causes the request to the page to have a funky trailing querystring. I've made the mistake of setting this up globally to fix some issues with jQuery and IE:

http://api.jquery.com/jQuery.ajaxSetup/

The other to look at here is the grouping of DB calls. Are you just making a lot of calls with one request? Are you executing a db command in a loop, within another reader? Code in this case would be helpful.

Good luck, I hope this helps!

这篇关于是什么让缓存从WebMatrix的工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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