What Caching is ?
Caching is a technique that stores a copy of a given resource and serves it back when requested.
In the web world we can make a first distinction between server side cache and client side cache.
Server Side Cache
As we know when we make a request to the server, it processes various operations: functions (objects) and requests to the database. Many of these can be cached on the server, thus speeding up the output response.
There are several extensions to set up cache server like memcached, php opcache, redis but simplifying the concept an example could be related of a sum function:
$z = $x + $y;
$z = $x + $y;
Instead of running this function as is every time we can modify this so that in addition to the result it creates a file with the result and we can cache this file. So if this file with the result exists we include it if it doesn’t exist we execute the function that returns the result and creates the file.
If we consider much more complex operations than a simple sum, this technique is a great advantage to optimize server responses.
In this way we can be more selective in choosing what to cache.
Instead of caching an entire file server, we can cache parts of a file.
Client Side Cache
Client-side caching is used for storing data files that could be useful to the user on their personal computer. Though there are various types of client-side caching, browser cache is the one we’ll explore below.
It’s nothing more than a place on your hard disk where the browser keeps things it downloaded once in case they’re needed again.
It’s faster to get something from your hard disk than it is to get it from the internet.
As a cache browser we also have two main distinctions here. One is http caching and the other is the html5 cache manifest.
Having made this brief and simple introduction to caching, I wish to introduce an even simpler insight:
why not make these resources in the browser cache sharable and make the browser cache interoperable ?