About
This article is talking about cache in the Web which is a feature of HTTP that:
- improves page load
- and reduce server load
Cache Implementation Step by Step
The how-to page gives a step-by-step idea of how to configure and test the HTTP cache.
Chain
There is three component in the route of an HTTP request/response, mainly:
- the client.
Each below section is talking about this process related to the cache.
Server
A web server does not cache any resource (the application on the server may cache) but controls how the resources (HTML, Javascript, …) that it send are cached via the several control cache Header.
The client (browser) and proxy will read this control cache Headers and implements their cache accordingly.
To understand and see the cache headers that have an impact on the cache, see this article: HTTP - Cache (Cache-Control Header, Bursting, )
Note that by pre-rendering a page, you may also implement an internal cache
Intermediate / Proxy
On the network, you can have proxy that may have their own cache store.
Client
Browser cache
The web browser cache will also read the control cache headers and implements its cache accordingly.
Service workers
If for many reason such as:
- disk space limitations,
- browser internal implementation,
- and limitations in the expressiveness of the HTTP cache specification (ie control cache headers)
the browser cache may not fulfill your requirement, you can always implements your own cache strategy with service worker for instance.
Specifications
The HTTP cache specification is covered in this two specifications:
- rfc7234 - Caching, R. Fielding, M. Nottingham, J. Reschke. IETF.
- rfc7232 - Conditional Requests, R. Fielding, J. Reschke. IETF.