代码之家  ›  专栏  ›  技术社区  ›  Russel Yang

为什么Firefox3.6.8不缓存asp.net开发者服务器?

  •  5
  • Russel Yang  · 技术社区  · 15 年前

    我正在做一件事asp.net像普通用户一样,我们使用asp.net在编码和测试期间开发服务器。 今天,我发现firefox没有缓存我的站点的任何静态文件,因为我们的应用程序非常大,这使得页面加载时间非常慢。 我查了火狐关于:缓存,所有静态文件缓存设置如下所示

               Key: http://localhost:26851/App_Layout/icons/actions/email/folder.png
         Data size: 871 bytes
       Fetch count: 1
     Last modified: 2010-08-19 11:59:46
           Expires: 1969-12-31 16:00:00
    
               Key: http://localhost:26851/Framework/ScriptLibrary/JQueryPlugins/ui.mouse.js
         Data size: 5079 bytes
       Fetch count: 1
     Last modified: 2010-08-19 11:59:39
           Expires: 1969-12-31 16:00:00
    

    Server  ASP.NET Development Server/9.0.0.0
    Date    Thu, 19 Aug 2010 22:10:27 GMT
    X-AspNet-Version    2.0.50727
    Cache-Control   public
    Etag    "1CB3F32C834A880"
    Content-Type    text/css
    Content-Length  1775
    Connection  Close
    

    Firebug还有一个标签叫做“cache”,信息是:

    Last Modified   Thu Aug 19 2010 15:10:27 GMT-0700 (Pacific Daylight Time)
    Last Fetched    Thu Aug 19 2010 15:10:27 GMT-0700 (Pacific Daylight Time)
    Expires Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)
    Data Size   1775
    Fetch Count 10
    Device  disk
    

    我使用的是visualstudio2008,windows7机器。应用程序在IE中运行良好,内容被正确缓存。

    以前有人见过这种行为吗?

    5 回复  |  直到 15 年前
        1
  •  4
  •   sanmai    15 年前

    你需要发布 到期 使Firefox缓存文件的头。

        2
  •  3
  •   Russel Yang    15 年前

    谢谢大家帮我解答这个问题。我相信我找到了FireFox在Windows7上运行缓慢的原因。当我使用WindowsXP时,我没有注意到它的缓慢。

    首先,Firefox不会缓存来自的任何资源asp.net web开发人员服务器。这一事实在XP或Windows7中没有改变。 当我今天使用firebug检查资源下载时,我注意到DNS查找需要几秒钟。然后我发现对于window7默认安装,windows\system32\driver\etc下的HOSTS文件没有DNS条目127.0.0.1 localhost。通过将此行添加到HOSTS文件。我的网站和以前一样快。

        3
  •  0
  •   mikek3332002    15 年前

    根据我的跑步记录 Fiddler2 ,它缓存文件,即304s(未修改)响应完成

    • 网络资源.axd

    IE 8和FF 3.6.8中都出现相同的行为 IE8必须设置为自动检查页面的新版本,才能发生这种情况。


    IIS


    此缓存是由于Web服务器添加了 last-modified 响应的标题。

    你可以让小提琴手听 localhost 通过使用 localhost. 相反( http://weblogs.asp.net/asptest/archive/2008/08/13/tip-on-using-fiddler-with-cassini-and-localhost.aspx

        4
  •  0
  •   Vinay B R    15 年前

    您可以尝试将其中一个添加到页面加载函数中-

            Response.ClearHeaders();
            Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
            Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 
            Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1 
            Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1 
            Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1 
            Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1 
            Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1
    

    方案2

    Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Response.Cache.SetNoStore()
    
        5
  •  0
  •   Shackles    15 年前

    您也可以在本地iiswebserver上托管该页,而不是在vsdevelopment服务器上运行它。在IIS中,您可以根据需要指定过期标头设置。

    推荐文章