As a web developer, you must have heard the term "cache" in various situations. To help you fully understand what cache means, we wrote this article.
When running a PHP script. The interpreter will parse the script into a series of operation codes, commonly known as "opcodes".
By caching the opcode in memory, we can gain significant performance improvement. This is known as opCode cache.
There is a list of well-know opCode cache engines and they are:
By default, PHP ships with Zend OpCache.
When building an application, we can utilize some cache strategies to avoid slow response:
Above are known as application cache.
When implementing the application cache, we have a lot of options in where to store the cache values. Following solutions are typically used to store the cache values:
Most of our PHP applications are built for the web and accessed by a browser. The browser interacts with our application via HTTP protocol.
By utilizing the HTTP cache headers, a browser stores the response locally in its cache, this saves it from requesting the same data again via the network. This is known as HTTP cache.
Commonly used HTTP Cache headers are:
OpCode cache, application cache, and HTTP cache are great to help with application speed improvement. However, all the requests still go through the webserver. When the concurrency of the application is high, the web server may have a difficult time handling the requests.
By placing a proxy server in front of the webserver, we can not only significantly reduce the web server's load, but also we can improve the speed greatly because proxy server stores the cached response inside its memory.
The strategy above is known as a proxy cache.
Well-known proxy cache servers are:
We hope you have understood different cache means through this article.