Caching benefits The Web cache is typically referred to as an HTTP device that can automatically save a copy of a common HTTP request. For front-end developers, the browser plays an important role. In addition to common, there are a variety of proxy servers can also be cached. When a Web request reaches the cache, the cache extracts the copy content from the local copy without needing to go through the server. This brings the following advantages: Cache reduces redundant data transfer
Caching benefits
Generally speaking, Web caching refers to an HTTP device that can automatically save a copy of a common HTTP request. For front-end developers, the browser plays an important role. In addition to common, there are a variety of proxy servers can also be cached. When a Web request reaches the cache, the cache 本地副本
extracts the copy content from it without needing to go through the server. This brings the following advantages:
- Cache reduces redundant data transfer and saves traffic
- Caching mitigates the bandwidth bottleneck problem. Load pages faster without the need for more bandwidth
- The cache mitigates instantaneous congestion and reduces the need for the original server.
- The cache reduces the distance delay because it is slower to load pages from farther away.
Cache type
The cache can be private to a single user, or it can be shared by multiple users. A private cache is known as 私有缓存
a shared cache 公有缓存
.
Private cache
Private caching is only for proprietary users, so it does not require much space and is inexpensive. Web browsers have built-in private caches--most browsers cache common resources in the disk and memory of your PC. For example, the cache location of the Chrome browser is located in: In C:\Users\Your_Account\AppData\Local\Google\Chrome\User Data\Default
the caches folder and the media cache folder.
Public cache
The public cache is a special shared proxy server, known as 缓存代理服务器
or 代理缓存
(a use of a reverse proxy). The public cache accepts access from multiple users, so it can better reduce redundant traffic.
Each client repeatedly accesses a resource to the server (which is not yet in the private cache), so it accesses the server multiple times, increasing server pressure. When using a shared public cache, the cache needs to be taken only once from the server and then no longer passed through the server, significantly reducing server pressure.
In fact, in practice, a hierarchical public cache is usually used, the basic idea is to use small inexpensive caches near the client, and at a higher level, the larger, more powerful caches are being used to load the resources shared by multiple users.
Server re-authentication
The cached resource in the browser or proxy cache is out of date, and does not mean that it is actually different from the resources on the original server, only that it is time to check. This condition is known as server re-authentication.
- If the resource changes, you need to get a new resource and replace the old resource in the cache.
- If the resource does not change, the cache only needs to get a new response header, and a new expiration time to update the resource expiration time in the cache. HTTP1.1 Recommended authentication method is
If-None-Match
/ Etag
, used in HTTP1.0 If-Modified-Since
/ Last-Modified
.
Web cache knowledge that the front-end should know