IIS(动态和静态)缓存、OutPutCache 和浏览器缓存有什么区别

What are difference between IIS (Dynamic and Static) cache,OutPutCache and browser cache(IIS(动态和静态)缓存、OutPutCache 和浏览器缓存有什么区别)
本文介绍了IIS(动态和静态)缓存、OutPutCache 和浏览器缓存有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IIS(动态和静态)缓存、OutPutCache浏览器缓存有什么区别?

我想我对他们感到困惑.

I think I'm confuse about them.

浏览器是否缓存所有的js或css文件?

Does browser cache all js or css files?

如果我使用 IIS 缓存而不使用 OutputCache 会发生什么?

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

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

What happend if I use both?

推荐答案

OutPutCache 是保存在服务器上的页面/控件缓存,用于从该页面/控件的渲染中获得处理速度.

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.

静态缓存是为所有用户共同的内容设置缓存,动态缓存是为同一页面设置不同的缓存并取决于用户或其他参数.你也可以说静态是不变的内容(例如图像,html页面等)的缓存,动态是像aspx页面一样变化的内容的缓存.

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 可以为图像和所有此类不变的内容设置缓存,并且您对浏览器说要保留长时间".

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.

浏览器是否缓存所有 js 或 css 文件?

Does browser cache all js or css files?

浏览器只做你说他做的事情.因此,您需要在浏览器的页眉上设置您希望浏览器将此文件保留在客户端缓存中的时间.如果你没有设置任何东西,那么 IIS 会为 Js 和 Css 和图像等静态内容设置文件创建日期,浏览器可以使用它来询问服务器是否需要再次读取它.

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.

关于静态和动态缓存的另一个信息是动态缓存上的浏览器询问服务器是否需要更新,如果答案是肯定的,则再次读取页面.这样浏览器总是调用服务器,但并不总是取回内容.

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.

您可以在 web.config 上设置此静态内容缓存

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.

一些示例:在 ASP.NET MVC 中创建 ETag 过滤器

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

在asp.net中为图片生成etags?p>

 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 : 请给我页面default.aspx

Client A Browser : Please give me page default.aspx

服务器响应:好的,请稍等.让我看看我在 OutpuCache 上有没有?不,我现在制作并将其保存到 OutPutCache.现在我发给你.(等待时间 600 ms + 70ms 网络延迟) + 2000ms 下载法师

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:请给我页面default.aspx

Client B Browser : Please give me page default.aspx

服务器响应:好的,请稍等.让我看看我在 OutpuCache 上有没有?是的,我从缓存中读取并发送它.`(等待时间 100 ms + 70ms 网络延迟)+ 2000ms 下载法师

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

客户端A浏览器:请给我页面default.aspx,我最后的缓存说该文件的日期:12/Mar/2012.

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

服务器响应 : hmm 你不需要重新读取它,因为它没有被修改,使用你的本地缓存.(等待时间 80 ms + 70ms Network Lag) + 0ms 下载页面

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

在 OutputCache 上找到页面时,用户不会等待页面开始显示这么多东西.

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 和浏览器缓存有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)