【译文】Disk cache VS Memory cache VS Browser cache

原文: What is the difference between Disk Cache , Memory Cache, Browser Cache ?

In general, a cache is a "more local" copy of a memory resource that you want to access.  
Its a copy that is faster to access than the original, but that memory is also more expensive.  

This link, provides some measurements that illustrate the benefits: http://norvig.com/21-days.html#answers

Disk cache is RAM memory, that contains a copy of the information on the disk.  
Typically, when you access something on the drive, the whole page is brought into cache, on the assumption that the next access will be in that page.   
The first disk seek might take 8ms, while seeks from cache 100 ns  (many times faster - note nanoseconds instead of milliseconds)

Memory cache is the same concept, but the cache is located on the CPU chip.  So the original memory access is 100ns, the L1 cache access can be 0.5 ns.

Browser cache is similar, but stores resources like images, javascript files, etc. on your hard-drive instead of the web page. 
Once you access a website, these static resources are stored locally in the browser cache for quicker access the second time you need it.  
Using the data from the link above, your access to an image on the web might take 150ms initially, but the second time only 8ms.  

Memory and Disk cache implementations will try to guess what you need to use next, while browser caches keep a local copy in case you need to use it again.  

一般来说,缓存(cache)就是您要访问的内存(memory)资源的本地副本。它的副本比原始副本的访问速度更块,但是这种缓存也更昂贵。

这个链接提供了一些衡量指标,已说明其好处:http://norvig.com/21-days.html#answers

为了方便下边解释,我把上边链接中的截图贴出来

Disk cache就是RAM内存(我理解就是平常说的类似于内存条那个内存),包含磁盘上信息的副本。通常,当你访问驱动器上的内容时,整个page会被带入缓存(内存),假设下次访问的内容还在那个page中。第一次磁盘搜索可能需要8ms,而从内存缓存中查找需要100ns(快很多倍-注意纳秒而不是毫秒)

Memory cache也是相似的概念,但是缓存位于CPU芯片上(我理解就是CPU高速缓存,现代cpu一般一共有3级缓存,一级比一级大,一级比一级慢,一级比一级便宜)。所以原来的内存访问是100ns,L1缓存访问可以为0.5 ns。

Browser cache也很类似,将图片,js文件等等资源存储在硬盘驱动器上而不是在网页上。一旦你访问一个网站,这这静态资源存储在本地浏览器缓存中,以便于您第二次需要时可以快速访问。使用以上链接中的数据发现,你首次通过网络访问一张图片可能需要150ms,但是第二次访问可能只要8ms。

Memory cache 和 Disk cache的实现是尝试猜测下一步需要使用的内容,然而Browser cache会保留本地副本,以防你需要再次使用它。

=========================================================================================

我一直的理解是Memory cache是RAM内存缓存(从字面上),这篇文章解释跟我的理解完全不一样,我在开启浏览器缓存是查看netWork一栏发现:

通过上图发现,Memory cache返回的都是一些很小的文件,而稍微大点的文件全是Disk cache返回的,我们一般用的电脑内存条一般都是 16GB,为啥Merory cache返回的都是小文件,我们运行内存缓存这些内容感觉还是够的,还有可能就是Merory cache真是如上文所说:实为CPU高速缓存,高速缓存肯定是很珍贵的,不只可能缓存一小部分方便你再次访问,附一张CPU高速缓存的图:

原文地址:https://www.cnblogs.com/hanshuai/p/14648491.html