头图

The difference between Client Side Cache and Server Side Cache

JerryWang_汪子熙
中文

Cache me outside

Caching is a persistence mechanism that optimizes web page loading time and optimizes the amount of memory used.

Definition of Cache

Due to space limitations, this article focuses on Web caching. When you load the website, website data (such as images, videos, and html documents) will be saved. After reloading the website, it will not call the database to get the data again. It just reads data from memory.

Cache trades capacity for speed. Cache usually temporarily stores a subset of data, while database data is usually complete and durable.

Client Side Caching

Client-side caching is often referred to as browser caching, although client-side caching is a slightly broader term. Its operating principle is shown in the figure below:

Once the browser requests data from the server, it stores it in the folder created by the browser. Next time you open the webpage, it will not call the server to get the data, but will fetch the data from the browser cache folder.

Server Side Caching

Server-side caching is a similar concept, but slightly more complicated.

Once a user makes a request to the website, its data is stored on the server. The next time the user makes a request, it only needs to retrieve the saved data from the server instead of extracting data from the database, thus saving time.

These caches are implemented by the site administrator and act as an intermediary between the browser and the origin server. They are also usually based on HTTP caching instructions.

Remote Caching

Remote caching is similar to server-side caching, but it can also run applications to serialize and deserialize data. The difference is that you can control the remote server instead of being operated by someone else.

Web content is usually retrieved through application code or using application frameworks that can take advantage of data storage in memory.

Server-Side vs Remote vs Client Side

The main difference is that the website data is stored locally in the client-side cache, while in the server-side cache it can be distributed to all users, while in the remote, the data is also processed.
Most well-designed websites or applications will use both the server side and the client side.

Why caching?

By reducing the load on back-end resources and network congestion, caching web content helps improve the responsiveness of the website. -AWS

Downside

If the website you’re trying to visit has been updated, you may not see the update until the cache is cleared. This may happen before you, especially if you are a web developer and you are trying to update the design of your website. If the cache is stored on your client, the solution is simple.

This applies to client-side caching. If the server-side cache does not handle this situation correctly, an error may be returned on the server-side cache.
If you use a remote cache, it can handle the error and clear the cache for you and load new requests for you.

In short, the client side cache:

Your web browser (Chrome, Firefox, Safari, or whatever browser you use) decides to remember the appearance of the web page, so there is no need to request the server to send the web page again. This saves time (and bandwidth) by eliminating almost the entire network communication. However, if the server decides to change the appearance of the web page, you will run into trouble, because the browser’s "memory" of what it thinks the page should look like is now outdated, and it will give you an old version of the page instead of the new one. . This is why people sometimes tell you to "clear your browser cache"-this will force your browser to "forget" the appearance of the page. This forces it to ask the server for a new, updated version of the page.

server side cache:

The server responsible for generating the webpage (that is, putting the webpage together) decides to remember the appearance of the webpage, so there is no need to generate it again. This saves time (but not bandwidth), because now the server does not have to go through the trouble of constructing the entire page-it can resend whatever was sent in the last browser request. However, if any data on the web page needs to be changed, the server will be forced to discard its "memory" of the appearance of the page and need to regenerate the page. This kind of caching is useful if the page is really complex and takes a lot of time to generate.

More original articles by Jerry, all in: "Wang Zixi":

阅读 308

Jerry Wang的SAP技术专栏
SAP成都研究院开发专家,SAP社区导师,SAP中国技术大使

Jerry 2007年从电子科技大学计算机专业硕士毕业后进入SAP成都研究院工作至今, SAP社区导师,SAP中国技术...

781 声望
1k 粉丝
0 条评论

Jerry 2007年从电子科技大学计算机专业硕士毕业后进入SAP成都研究院工作至今, SAP社区导师,SAP中国技术...

781 声望
1k 粉丝
文章目录
宣传栏