问题描述
什么是 IIS(动态和静态)
缓存的OutputCache
和浏览器之间的差异缓存
?
我想我迷惑他们。
是否浏览器缓存中所有的JS和CSS文件?
发生了什么,如果我使用 IIS
缓存和不使用的OutputCache
?
发生了什么,如果我同时使用?
的的OutputCache
是保存在服务器从渲染的增益处理速度的页/控制缓存此页/控制。
的浏览器缓存
是头命令你页面上设置,并给予指令给客户浏览器保持对客户端计算机的缓存页面一段时间,没有看过从服务器返回。
的静态缓存
是,当你设置的内容缓存是常见的所有用户,而动态高速缓存
如果当您设置缓存,它在同一页的不同,从用户或其他参数依赖。你也可以说,静态的是一个未更改内容(如图像,HTML页面等)和动态是,像aspx页面更改内容缓存。
IIS可以设置图像和所有这种类型的未改变内容的缓存和你在浏览器说,保持对长的时间。
您需要使用的所有缓存的组合,以获得最好的结果,而不是用什么,什么不是。大部分缓存静态内容未发生很大的变化,动态内容缓存较少。
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和浏览器缓存的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!