本帖最后由 cceon 于 2013-07-06 02:14:00 编辑

解决方案 »

  1.   

    在提交的程序里 清楚缓存、     //清除该页输出缓存,设置该页无缓存 
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
            context.Response.Expires = 0;
            context.Response.CacheControl = "no-cache";
            context.Response.AppendHeader("Pragma", "No-Cache");  试试  看
      

  2.   

    试了下,用了楼上的代码,页面的OutputCache就没有了
      

  3.   

    直接访问news.aspx有输出没?没有就是news.aspx有问题。
      

  4.   

    news.aspx 独立访问的话 始终都有输出的news.aspx 不设置 OutputCache 的话,$.getJSON 一直都ok,没有问题news.aspx 设置了 OutputCache 的话,$.getJSON 第一次ok,以后就获取不到了(除非OutputCache过时长了)
      

  5.   

    用firebug监视下发出了请求了吗
      

  6.   

    <%@ OutputCache Duration="600" VaryByParam="date;r"%>  
    页面级缓存中,你VaryByParam属性中仅单独针对date参数做出了缓存定义。所以
    news.aspx?date=1&r=0.1353
    news.aspx?date=2&r=0.6989
    这两个返回的结果会是相同的,VaryByParam属性可同时配置多个参数以做区分,多个参数用分号分隔开如果上述方法可以解决你的问题,那就再多说一句。既然使用了r: Math.random()做动态的随机参数,你的页面级缓存的设置就已经毫无意义
      

  7.   

    楼上说的完全对,我也刚刚找到这个问题
    jsonp=? 和 r 每次都产生不同的值,news.aspx页面虽然独立访问的时候都没有错,但是jsonp的值变化这就是为什么独立访问news.aspx都是OK的原因
    home.html 第一次调用是:news.aspx?jsonp=jQuery180043238143413327634_1373202466179&date=2013-7-1&r=0.123
    这时候,news.aspx返回是jQuery180043238143413327634_1373202466179([{id:1,title:'标题1'}])
    再次调用是:news.aspx?jsonp=jQuery18003844868973828852_1373202580388&date=2013-7-1&r=0.456
    这时候,news.aspx返回依然是jQuery180043238143413327634_1373202466179([{id:1,title:'标题1'}])所以,就像楼上所说的,页面级缓存毫无意义,
    解决办法是在news.aspx页面里面,把需要缓存的内容,根据日期缓存起来,其他动态内容依旧,这样就ok了
    以下代码是ashx文件的部分代码
    StringBuilder sb = new StringBuilder();
    string CacheName = context.Request.QueryString["date"].ToString();//缓存名称
    if (context.Cache[CacheName] == null)
    {
    List<Article> l = Article.GetNews(DateTime.Parse(date.ToString()));//这段就是访问数据库
    foreach (Article a in l)
    {
    sb.Append("{\"id\":\"" + a.ID + "\",");
    sb.Append("\"title\":\"" + a.Title + "\"},");
    }
    if (sb.ToString().EndsWith(","))
    {
    sb.Remove(sb.Length - 1, 1);
    }
    context.Cache.Insert(CacheName, sb, null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);//10分钟缓存
    }
    else
    {
    sb = (StringBuilder)context.Cache[CacheName];
    }
      

  8.   

    所以就导致jquery再次调用时要执行jQuery18003844868973828852_1373202580388([{id:1,title:'标题1'}]),
    但是news.aspx返回了:jQuery180043238143413327634_1373202466179([{id:1,title:'标题1'}])注意:以上jQuery后面的一串数字是不一样的