Private vs. Public Content

There are two types of content: public content and private content. Public content is information that can be served to all visitors. Private content is specific to individual users. For example, look at a product page on an eCommerce site: most of the page is public content because it is the same for everyone, but the header may contain “items in cart” information or a personalized greeting, both of which are considered private content.
How LSCache With ESI Helps

Generic caching solutions are typically limited to caching pure public content. There are two solutions to handling this problem:
- Load the public content, and then use Ajax to retrieve the private content. (This option increases the amount of requests significantly and requires higher end server hardware to handle the same amount of users.)
- Use ESI to punch holes for the private content and let the server assemble it from cache. (This option is more efficient overall, but is not easy for a generic cache proxy to implement.)
LiteSpeed Cache with ESI is different. When using any of the LSCache plugins, the cache potential is significantly greater, because the cache engine is at the server level. The plugins do not execute the caching functions. They instead provide insight for the server. When content on the site changes, the plugin notifies LSWS to purge the related cache entries. For example, if a user adds/removes an item from the cart, the cart ESI block will be purged automatically. Pages can be given a longer time to live (TTL) - days, weeks, months - as the plugins will indicate when the page content is outdated. This is possible through LiteSpeed’s intelligent tag-based cache system. Using LSCache, only one request will be served, and the server will assemble the public and private cache content into one full page. And it will do so while using significantly fewer server resources than Ajax.
By integrating the ESI engine and the cache engine into our servers, LiteSpeed is able to provide the best caching solution in the industry.
How Does It Work

ESI allows an application to “punch holes” in a publicly cached page. Then, those holes may be filled with private or public content as appropriate. With ESI, punched holes can be treated differently than the rest of the page. They can have different TTLs and be purged by events that are completely separate from the page they are on. This allows users to accurately cache more of their site for more of their visitors.
With the ability to punch holes for private content, ESI enables most of a site’s pages to be considered publicly-cacheable; a page no longer has to be deemed non-cacheable only because a section of it is non-cacheable. Allowing that section to be cached privately (while the rest of the page remains in public cache) optimizes space usage and speed.
Using technologies such as Hole Punching, Private/Public Cache separation, and Flexible Cache Control via rewrite rules and response headers, LiteSpeed can assemble and serve dynamic web pages entirely from cache without backend server interaction. To see for yourself how ESI improves performance, check out our benchmarks.
To learn more about ESI please visit our Wiki.