English 中文(简体)
经典ASP - IIS 5到IIS 6迁移会导致图像缓存问题?
原标题:
  • 时间:2008-11-20 09:19:40
  •  标签:

提前道歉,问题有些冗长。

我真正是一位数据库程序员,但我继承了对一个Classic-ASP Intranet应用程序的支持,该应用程序最近已经从IIS 5迁移到了运行IIS 6的新服务器。用户基础约为十几个,全部使用IE 6。

用户界面显示来自数据库的项目层次结构,使用HTML无序列表和JavaScript的组合,在用户浏览时隐藏/展开分支。

使用CSS(使用list-style-image)将图像显示在列表成员旁边,每种类型的项目使用不同的图像。层次结构中不同项目类型(因此图像)的数量在2到10之间变化。层次结构在20到200个项目之间变化。

The problem:

自迁移到IIS 6以来,几个用户发现一个问题,可能是由于一些图像未能正确应用到层次结构中的一个或多个项目引起的;列表显示正确,但一个或多个图像丢失,点击任何链接会导致加载空白页。

使用Wireshark和IIS日志分析网络流量显示问题不在服务器端 - 所有内容都已正确提供给客户端。

The issue appears to be related to content caching at the client: it seems to more often affect users who have not used the application before on their current PC, or have not used it for some time. Also, I can replicate the issue approximately one attempt in three by starting a session, clearing my browser cache and then refreshing the page. However, the same is true of the application when running on IIS 5, so this issue may have existed before the migration to IIS 6 but have happened less frequently. Occasionally, if I leave the session for 20 minutes or so, the browser seems to "find" the missing images, and everything works OK.

If the application is accessed through a local proxy (I used Fiddler) the problem never occurs, although the Fiddler connection log shows one or more connections made to the server to retrieve the images has aborted. As before, network traffic shows that the image was returned by the server. However, using the proxy seems to enable IE to find other successfully retrieved copies of the image from the cache.

I ve reached the point where I m at the end of my limited knowledge of debugging ASP/IIS issues. Removing the list-style-images from the CSS fixes the problem, but this has to be the option of last resort since it makes the application more difficult to use.

Any suggestions on how I can proceed would be gratefully received.

编辑

AnonJr建议这可能是客户端配置问题,因为所有其他组件似乎都在正常运作。

I discounted a simple client configuration issue because this is the only application affected by the issue described I have tested all the options under Tools > Internet Options > Temporary Files > Settings with no change in behaviour.

What other client configuration options should I be considering?

编辑2-解决方案 (Biānjí 2- jiějué fāng'àn)

接受的答案促使我搜索IE6的已知问题,即在从客户端脚本生成HTML时请求多个图像副本- http://support.microsoft.com/default.aspx?scid=kb;en-us;319546

这篇文章(指出这种行为是“按设计操作”)建议通过将所需图像加载到不可见的DIV中进行预加载来解决问题。

<DIV style= display:none ><IMG SRC= image.gif ></DIV>

这似乎对我有效-我无法通过在会话中清除我的浏览器缓存来再现问题,而 Fiddler 追踪显示每个图像仅被请求一次。

我发现了一个以前不知道的警告; IE缓存是大小写敏感的,因此只有当隐形DIV中指定的文件名的大小写与页面中其他地方使用的匹配时,才会使用缓存的图像。

最佳回答

这听起来像是IE6的一个bug,即浏览器会多次请求相同的资源。例如,如果内容要求在列表中显示20次重复的小图标,它会试图获取该图像20次,而不是仅获取一次。好的,19个响应是304未修改,但仍然需要19个额外的往返服务器的请求。

我过去发现,这种过度请求最终会导致太多未完成的请求。在那一点上,即使是针对其他页面的进一步请求,也会难以得到服务器的响应,至少一段时间内都是如此。

我不确定这是否是您的情况,一种检查方法是使用IE7来查看您是否遇到相同的问题,这个错误在IE7中已经修复。

编辑:现在问题已被确认为我所指的错误,你还应该注意到KB的参考,这里有一个短暂的延迟。问题的根源是为了重复使用新获取的图像,浏览器需要完成一些工作,这些工作被延迟到当前 JavaScript 块完成之前。需要不止一个短暂的延迟,还需要采用一种异步的方法。

我使用过display:none DIV方法来预先获取图像,这对于AJAX风格的工作非常有效。但是,如果您在窗口的onload事件期间或之前运行代码,则在此代码中添加图像仍然会存在问题。需要使用setTimeout使得在onload事件完成后能继续执行其他代码。

问题回答

您可能希望将注意力集中在调整客户端缓存设置上。如果图像是由服务器发送的,那么它不太可能是一个IIS问题。如果图像的HTML被发送到浏览器,那么它不是一个ASP问题。那就剩客户端了。

代理服务器可能会缓解一些问题,并且/或者可能会影响IE6决定缓存图像等的因素。





相关问题
热门标签