什么是IIS(动态和静态)缓存的OutputCache和浏览器缓存的差异 [英] What are difference between IIS (Dynamic and Static) cache,OutPutCache and browser cache

查看:280
本文介绍了什么是IIS(动态和静态)缓存的OutputCache和浏览器缓存的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 IIS(动态和静态)缓存的OutputCache 浏览器之间的差异缓存

我想我迷惑他们。

是否浏览器缓存中所有的JS和CSS文件?

发生了什么,如果我使用 IIS 缓存和不使用的OutputCache

发生了什么,如果我同时使用?


解决方案

的OutputCache 是保存在服务器从渲染的增益处理速度的页/控制缓存此页/控制。

浏览器缓存是头命令你页面上设置,并给予指令给客户浏览器保持对客户端计算机的缓存页面一段时间,没有看过从服务器返回。

静态缓存是,当你设置的内容缓存是常见的所有用户,而动态高速缓存如果当您设置缓存,它在同一页的不同,从用户或其他参数依赖。你也可以说,静态的是一个未更改内容(如图像,HTML页面等)和动态是,像aspx页面更改内容缓存。

IIS可以设置图像和所有这种类型的未改变内容的缓存和你在浏览器说,保持对长的时间。

您需要使用的所有缓存的组合,以获得最好的结果,而不是用什么,什么不是。大部分缓存静态内容未发生很大的变化,动态内容缓存较少。


  

是否浏览器缓存中所有的JS和CSS文件?


你说什么他做浏览器只能做。所以,你需要在页面页眉设置为浏览器多久你喜欢的浏览器保持对客户端缓存此文件。如果您没有设置任何东西,然后像JS和CSS和图像文件创建日期静态内容设置IIS,这可以通过浏览器可用于向服务器回来,如果他需要再次或没有看过。

静态和动态

有关静态和动态高速缓存还有一个信息是,在动态高速缓存的浏览器向服务器请求,如果他需要更新,如果答案是肯定的然后再次读取页面。以此方式,浏览器总是调用服务器,但并不总是取回内容<​​/ P>

另一种方法是静态的,在该高速缓存中的浏览器高速缓存中的内容以及不问服务器重新读取。例如,对于那些静态内容的图像,你设置一个大的缓存和浏览器就不会再问服务器,但来自客户端的缓存中使用的图像。

您可以设置在web.config中该静态内容缓存

 &LT; staticContent&GT;
    &所述; clientCache cacheControlMaxAge =8.00:00:00cacheControlMode =UseMaxAge/&GT;
&LT; / staticContent&GT;

针对浏览器的动态高速缓存是,你需要做出一些编程。您可以设置一个parametre的标题,当浏览器请求内容阅读本parametre你deside重播什么,用新的内容或命令从缓存中读取。

一些例子:创建ASP.NET MVC ETag的填料

<一个href=\"http://jagbarcelo.blogspot.com/2009/03/conditional-get-and-etag-implementation.html\">http://jagbarcelo.blogspot.com/2009/03/conditional-get-and-etag-implementation.html

生成的ETag的图像asp.net?

 如果我同时使用IIS缓存的OutputCache?

其实这是两种diferent认为行为由他们自己。让我们看看什么happends一些步骤。

客户端浏览器:请给我的Default.aspx页

服务器性反应:好的稍等一下。让我们看为什么我有它在OutpuCache?不,我现在做它,将它保存到的OutputCache。现在我把它发送给你。 (等待时间600毫秒+ 70ms的网络延迟)+ 2000毫秒下载法师

客户端B浏览器:请给我的Default.aspx页

服务器性反应:好的稍等一下。让我们看为什么我有它在OutpuCache?是的,我是从缓存中读取它,并将其发送。 `(等待时间100毫秒+ 70ms的网络延迟)+ 2000毫秒下载法师

客户端浏览器:请给我的Default.aspx页,我的最后一个高速缓存说该文件具有日期:12 /三月/ 2012。

服务器性反应:嗯,您并不需要重新读它,因为不被修改,使用本地缓存。 (等待时间为80ms + 70ms的网络延迟)+ 0毫秒下载页

上的OutputCache发现页对于用户的影响是不是等待页以开始展示如此多的财产以后。

在页面发现没有修改,其效果是,用户看到的网页几乎正道,因为不是等待页面下载。

在内容是静态的(如图像),并在缓存中找到,然后在浏览器显示与出正确的方式要求该服务器,所以这是更快的可能的方式,用户看到的东西,是在本地缓存。

What are difference between IIS (Dynamic and Static) cache, OutPutCache and browser cache?

I think I'm confuse about them.

Does browser cache all js or css files?

What happend if I use IIS caching and don't use OutputCache?

What happend if I use both?

解决方案

The OutPutCache is a page/control cache that saved on server to gain processing speed from the render of this page/control.

The browser cache is header commands that you set on page and give the instruction to the clients browser to keep the page on clients computer cache for some time and not read it back from the server.

The static cache is when you set cache for content that is common for all users, and the Dynamic cache if when you set cache that is different for the same page and depend from the user or for other parameters. Also you can say that static is the one for the content that is not change (eg images, html pages etc) and dynamic is the cache for the content that change like aspx pages.

IIS can set a cache for the images and all this type of content that is not change and you say to the browser to keep for 'long' time.

You need to use a combination of all cache to get the best result and is not what to use and what not. Much cache for static content that is not change a lot, less cache for dynamic content.

Does browser cache all js or css files?

Browser do only what you say him to do. So you need to set on page headers to the browser for how long you like browser keep this files on client cache. If you not set anything then the IIS set for static content like Js and Css and images, the file creation date, and this can be used by the browser to ask the server back if he need to read it again or not.

Static and Dynamic

One more informations about static and dynamic cache is that the browser on dynamic cache ask the server if he need update and if the answer is yes then read again the page. This way the browser always call the server, but not always get back the content.

The other way is the static, in this cache the browser cache the content and never ask the server for re read it. Eg for the images that are static content you set a big cache and the browser never ask again the server but use the images from the client cache.

You can set this static content cache on web.config

<staticContent>
    <clientCache cacheControlMaxAge ="8.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>

The dynamic cache for the browser is something that you need to make programmatically. You set a parametre on header, and when the browser ask for a content you read this parametre and you deside what to replay, with the new content or with a command to read from the cache.

Some examples: Create ETag filler in ASP.NET MVC

http://jagbarcelo.blogspot.com/2009/03/conditional-get-and-etag-implementation.html

Generating etags for images in asp.net?

 if I use both IIS cache and OutputCache?

Actually this is two diferent thinks that acts by them self. Let see some steps for what happends.

Client A Browser : Please give me page default.aspx

Server Responce : Ok wait a bit. Let see did I have it on OutpuCache ? No, I make it now and save it to OutPutCache. Now I send it to you. (waiting time 600 ms + 70ms Network Lag) + 2000ms to download the mage

Client B Browser : Please give me page default.aspx

Server Responce : Ok wait a bit. Let see did I have it on OutpuCache ? Yes, I read it from cache and send it. `(waiting time 100 ms + 70ms Network Lag) + 2000ms to download the mage

Client A Browser : Please give me page default.aspx, my last cache say that the file have date: 12/Mar/2012.

Server Responce : hmm You do not need to re-read it because is not modified, use your local cache. (waiting time 80 ms + 70ms Network Lag) + 0ms to download the page

When the page found on OutputCache the effect for the user is that is not waiting for the page to start showing somthing so much.

When the page found not modified, the effect is that the user see the page almost right way because is not wait for the page to download.

When the content is static (like image) and found on cache, then the browser show it right way with out asking the server, so this is the faster possible way that the user see something that is on local cache.

这篇关于什么是IIS(动态和静态)缓存的OutputCache和浏览器缓存的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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