Table of contents of the article:
The word cache can take on different meanings and functions depending on the different contexts in which it is used. In particular, there are three main uses of the word cache: the site cache, the browser cache and the server cache.
The browser cache is a temporary memory used by the browser to speed up the loading of web pages. When a user accesses a web page, the browser downloads the contents of the page and stores them in the browser cache. This way, if the user accesses the same page again in the future, the browser can use the cached content to load the page faster, without having to download all the content from the server again. Browser cache is managed by the browser and can be cleared or configured according to user preferences.
The server cache is temporary storage used by the server to speed up processing of client requests. When a client sends a request to the server, the server processes the request and caches the results in the server. This way, if another client sends a similar request in the future, the server can use the cached results to provide a faster response, without having to process the request all over again. The server cache is managed by the server and can be configured according to the needs of the system administrator.
What are site, browser and server caches?
It is useful to demystify which site caches, browsers and servers are before breaking down each of them by their differences. Knowing what they are helps make their differences more pronounced.
Each of these cache types are described in detail below.
What is a site cache (or page cache)?
A site cache, also known as an HTTP or pages,is a system that temporarily stores data such as web pages, images and similar multimedia content when a web page is first loaded.
It stores the content and is able to load the content quickly every time the web page is visited again.
It works similar to a person's memory. Once you've memorized something like the 12 x 12 answer, you can easily recall it later when someone asks you for the answer.
Also, you can repeat the answer quickly every time.
When a user visits a page for the first time, a site cache commits the selected content to memory. When the same page is visited again, the site cache is able to recall the same content, thus loading it much faster than on the first visit. Each visit to the same page loads equally quickly from the cache.
When using site cache to do this, it is referred to as “caching”. Site caching is the concept of client-side caching.
This means that caching is fully taken care of and controlled by the end user. A website has only a limited way of administering client-side caching. It can tell a cache how long to store saved data.
This way, a page with content that doesn't change often can be set to expire later in the future. However, a page with images that change often, for example, may be required to expire long before or when the page is refreshed.
This way the end user can regularly view updated content. However, pages that have not been modified can still be loaded from the cache to speed up the time it takes to load the page.
What is a browser cache?
A browser cache is a type of client-side cache, which means it is also a type of site caching. It works the same way and is a caching system that is integrated into a browser.
The files and contents saved are stored on your computer and are grouped with other files associated with the browser used.
A browser cache temporarily saves these types of content:
- HTML pages
- CSS style sheets
- Other types of multimedia content
According to Google, every browser has some form of browser cache. Although, some have a more complete system like those found in major options like Chrome, Safari, Firefox, and other similar browsers.
As mentioned above, a website can communicate with a user's browser. So when a page is refreshed and the cached content is out of date, the browser knows it should empty the old content and save the updates in its place.
The end user can also manually clear the browser cache whenever they want.
What is a server cache?
A server cache is a type cache that is related to site caching, except that instead of temporarily saving client-side content, it is stored on a site's server. Server caching is also fully managed and managed on the server without any involvement of the end user or a browser.
Among the most famous Cache Servers we know Varnish, flagship of our hosting infrastructure and extensively covered in this article.
Server caching types include, but are not limited to:
- Object caching - Storage of database queries in a server-side cache for quick retrieval on subsequent page loads.
- CDN caching - A content delivery network (CDN) is a cluster of servers that are geographically located around the world. They cache uploaded content using the server closest to the end user for much faster loading times.
- Opcode caching - PHP code is compiled between each request, then cached so that it is executable faster on repeated page loads.
Using a server cache for temporary storage is referred to as server-side caching or can be referred to as “caching” for general conversation use.
Comparison of the different caches.
Now that the website, browser, and server caching have been defined, you can see the differences. But, putting them all out can help you understand them better.
Here are the main details about caching:
- A cache temporarily stores content for faster retrieval on repeated page loads.
- Using a cache for storage is called “caching”.
The following are the differences between each cache type, summarized for clarity:
- A site cache saves certain types of content and is controlled on the client side.
- A cache of the browser saves the same types of content and is saved on your computer, via the browser, and is controlled by the browser. It is a type of client-side cache.
- The server caches archive content, code, query, or similar data on a server or multiple servers and is controlled by the server rather than by a browser (client) or user.
Regarding the Server Cache, we invite you to read how the Varnish cache.