如何检查图像是否是从缓存中 [英] How to check whether the images are from cache

查看:95
本文介绍了如何检查图像是否是从缓存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查图像是从高速缓存或从服务器。由于我的主页包含45图像。当我preSS <大骨节病> F5 ,想知道图像是从高速缓存或从服务器中。

How to check whether the images are from cache or from server. Since my home page contains 45 images. When I press F5, want to know whether the images are from cache or from server.

我已经加入&LT;%@的OutputCache时间='120'位置='客户'的VaryByParam ='无'%GT;

推荐答案

新的游客当然不会有任何缓存图像,而他们也希望自己的网站能快速加载。如果您测试您的网站如何执行它们,然后简单地清除缓存?

New visitors will of course not have any cached images, while they also want your site to load fast. If you're testing how well your site performs for them, then simply clear your cache?

如果它只是用于调试:


  • 野生具有Developer菜单,这可以通过preferences启用。在这里,在Web检查资源选项卡会显示0毫秒的东西时,从缓存加载。查看详细信息,你会看到该请求头在这种情况下失踪(虽然旧的响应头仍然可以查看)。

  • 使用火狐href=\"https://addons.mozilla.org/firefox/addon/3829\" rel=\"nofollow\">直播HTTP头的的If-Modified-Since的头。)

  • 火狐与萤火虫附加安装给你Net标签,但在启用时,Firefox将会总是的要求,即使你没有点击刷新,但只是跟随一些链接(这样的总是的使用的If-Modified-Since的头,见下文)。这仍然会告诉你不修改虽然。萤火虫的一些精简版的版本也适用于Internet Explorer。

  • Safari has a Developer menu, which can be enabled through the preferences. Here, the Resources tab in the Web Inspector will show 0 ms when something is loaded from cache. Viewing the details, you'll see that the request header is missing in those cases (though the old response header can still be viewed).
  • Using Firefox with the Live HTTP Headers add-on will show you exactly what is requested from the server. If it is not requested, then it was loaded from the cache. (In that case, nothing is requested, not even using a If-Modified-Since header.)
  • Firefox with the Firebug add-on installed gives you the Net tab, but when that is enabled Firefox will always request all content again, even if you don't click Refresh but are just following some links (thus always using a If-Modified-Since header, see below). This will still show you "Not Modified" though. Some lite version of Firebug is also available for Internet Explorer.

请注意,按F5 /刷新将使大多数浏览器的总是的要求服务器,如果事情已经改变了该浏览器已缓存的内容,即使它知道缓存应仍有效。然后,请求将包括的If-Modified-Since的头。如果服务器认为它没有修改,则使用高速缓存。这样的:

Note that hitting F5/Refresh will make most browsers always ask the server if something has changed for the content which the browser already cached, even if it knows that the cache should still be valid. The request will then include a If-Modified-Since header. If the server says it's not modified, then the cache is used. Like:

GET /ga.js HTTP/1.1  
Host: www.google-analytics.com  
...  
If-Modified-Since: Mon, 22 Jun 2009 20:00:33 GMT  
Cache-Control: max-age=0  

HTTP/1.x 304 Not Modified  
Last-Modified: Mon, 22 Jun 2009 20:00:33 GMT  
Date: Sun, 26 Jul 2009 12:08:27 GMT  
Cache-Control: max-age=604800, public  
Server: Golfe

以上是只是导航的网站不同。当点击链接,或在一段时间后回来一个页面时(键入地址,书签,搜索结果,...)浏览器会直接安静的使用缓存,如果它仍然是有效的,不问如果有什么发生了变化。

The above is different from just navigating a site. When clicking links, or when coming back to a page at some later time (typing the address, bookmarks, search result, ...) a browser will simply silently use the cache if it is still valid, without asking if anything has changed.

(还要注意的是代理服务器,可能会做一些缓存。在上面的响应,公共的Cache-Control 表示代理确实可以缓存特定响应。)

(Also note that a proxy server may do some caching. In the above response, the public in the Cache-Control indicates that a proxy can indeed cache that specific response.)

这篇关于如何检查图像是否是从缓存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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