HTTP caching involves storing responses stemming from past requests and making those responses reusable in the future. Delivering the request to the origin server isn't necessary, and caching impact tends to scale with greater client proximity.
There are two main HTTP caching methods:
Private caches – Caches tied to specific clients, like browser caches, which contain information that isn't shared with any other clients. These cached responses are thus personalized and typically controlled by cookies (though not exclusively).
Shared caches – Including proxy caches and managed caches, shared caches store responses that multiple users can use. These sit between clients and servers. These caches provide a mix of access control, outgoing network traffic reduction, and server offloading. Managed caches are typically more flexible because they allow deletion and greater control using a variety of mechanisms.
Why is HTTP caching useful?
Because HTTP caches store old responses instead of sending new ones, content reaches users more quickly. Data is readily available—as it would be within a browser cache—which can improve loading times and overall user experiences. Caches reduce overall server loads and shorten the data pathways between users and web application backends.
Plus, our oversight over caching behaviors (such as Cache-Control
, no-store
, no-cache
, max-age=
, etc.) has privacy implications. It's possible to "clean up" these caches to prevent accumulating outdated or unneeded data.
Does HAProxy offer HTTP caching?
Yes! HTTP caching (like HTTP compression and others) is one of our key application acceleration features. HAProxy offers many methods for controlling how caches behave and serving stored responses directly from the load balancer. Caching applies to any reusable information that's safe to share among clients, including the following:
CSS, JavaScript, and icon files
API responses without client-specific data
Small and static HTML pages
HAProxy caches run in memory and never store states on disk. To learn more and better understand any impacts, check out our caching documentation.