Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:cache:lscwp:esi [2017/09/01 15:42]
Lisa Clarke Simplified text, made it less "chatty"
litespeed_wiki:cache:lscwp:esi [2024/03/18 18:42] (current)
Lisa Clarke Redirect to new Documentation Site
Line 1: Line 1:
-====== LSCWP and ESI ====== +~~REDIRECT>​https://docs.litespeedtech.com/​lscache/lscwp/cache/#esi-tab~~
-As of version 1.2, [[https://wordpress.org/​plugins/​litespeed-cache/​|LiteSpeed Cache for WordPress]] now includes [[https://​en.wikipedia.org/​wiki/​Edge_Side_Includes|Edge Side Includes]], also known as ESI. +
- +
-//Please note: OpenLiteSpeed does not support ESI functionality. You will need [[https://​www.litespeedtech.com/​products/litespeed-web-server|LiteSpeed Web Server Enterprise]],​ or [[https://​www.litespeedtech.com/​products/​litespeed-web-adc|LiteSpeed Web ADC]] in order to use ESI.// +
- +
-===== What is ESI? ===== +
- +
-With ESI, pages may be served from cache for logged-in users. +
- +
-ESI allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. In other words, ESI lets you “punch holes” in a page, and then fill those holes with content that may be cached privately, cached publicly with its own TTL, or not cached at all. +
- +
-**Note**: ESI doesn'​t come without a cost. It is much simpler for the server to return full pages than it is for it to piece together pages from several different blocks, and so this must be a factor in your decision to enable ESI. Will the speed benefits outweigh the efficiency hit? There'​s no easy answer. It depends on your site. +
- +
-===== Public Cache vs. Private Cache ===== +
- +
-LiteSpeed Cache has built-in public and private caches. In the public cache you will find pages that are exactly the same for everyone. Private caches contain content that pertains only to a specific user specified by his/her IP address and session ID. +
- +
-===== How do ESI and Public/​Private Cache Work Together? ===== +
- +
-ESI allows you to disassemble a full page and treat the pieces differently from each other. +
- +
-LiteSpeed Web Server allows you to store content in either the public cache or a private cache. +
- +
-Combine these two elements and you get something very powerful. You get a system that can break apart a page into public and private pieces, cache each piece appropriately,​ and then re-compose the full-page content from the relevant caches and serve it to a user without ever hitting the PHP backend. +
- +
-**This combination allows you to cache content for logged-in WordPress users.** With ESI enabled you can cache a full page, punch holes in it for the private content, and save that content in the private cache. +
- +
-===== Examples ===== +
- +
-==== Example ​#1: Admin Bar ==== +
- +
-A logged-in site admin visits the publicly-cached home page: +
- +
-**Without ESI**: the request hits the backend, because the admin bar at the top of the page is private content, and as such this page (and every other page on the site, for that matter) cannot be served to the admin from cache. +
- +
-**With ESI**: most of the this page is served from the public cache, while the admin bar is served from the site admin'​s private cache. There is no need to invoke PHP. +
- +
-==== Example #2: Recent Posts Widget ==== +
- +
-A large site with much static content that rarely changes includes a "​Recent Posts" sidebar widget on each page. +
- +
-**Without ESI**: Every time a new post is published, every single page in the site must be purged so that the widget displays up-to-date data. Re-populating the entire cache requires a crawler to run, or visitors to hit all of the pages of the site. +
- +
-**With ESI**: All of the pages in the site can remain cached with a long TTL, while the Recent Posts widget is the only thing that needs to be purged. Re-populating the widget in the cache requires just one visitor to request any page one time. +
- +
-===== Enabling and Configuring ESI ===== +
- +
-LiteSpeed Cache for WordPress considers all cacheable full-pages to be publicly-cached. +
- +
-When you enable ESI, you allow holes to be punched for content that will either be privately-cached,​ publicly-cached with its own TTL, or not cached at all. +
- +
-Once enabled, the following ESI blocks are created by default: +
- +
-  * Admin Bar +
-  * Comments +
-  * Comment form +
-  * Recent Posts widget +
-  * Recent Comments widget +
- +
-Any widget can be an ESI block if you want it to be. By default, ESI is disabled for all but the two widgets listed above, but you can change that in WP Admin. +
- +
-==== Basic ESI Settings ==== +
- +
-{{:​litespeed_wiki:​cache:​lscwp:​wpwzzzb.jpg?​700|}} +
- +
-Navigate to **WP Admin > LiteSpeed Cache > Settings > ESI Settings**. Set **Enable ESI** to `''​Enable`''​. +
- +
-This creates the ESI blocks listed above. The blocks will remain uncached, unless you enable them via the **Cache Admin Bar** and **Cache Comment Form** settings. +
- +
-==== Creating new Widget ESI Blocks ==== +
- +
-{{:​litespeed_wiki:​cache:​lscwp:​wpwzzzc.jpg?​500|}} +
- +
-Navigate to **WP Admin > Appearance > Widgets** and select the widget that you want to turn into an ESI block. +
- +
-By default a widget is not considered an ESI block (unless it is Recent Posts or Recent Comments, as mentioned above). If you want the widget to be treated differently than the pages on which it appears, set one of the following configurations in the shaded "​LightSpeed Cache" area: +
- +
-=== Private widget === +
- +
-The contents will be stored in private cache, different copies for each user by IP/session ID. (Examples: a list of recently-viewed posts, or a personalized greeting.) +
- +
-  * Set **Enable ESI** to `''​Private''​`. +
-  * Set **Widget Cache TTL** to a value appropriate for the contents of the widget. +
- +
-=== Public widget === +
- +
-The contents will be stored in public cache, with each user seeing the exact same thing. (Examples: a list of recent posts, or a calendar of upcoming events). +
- +
-  * Set **Enable ESI** to `''​Public''​`. +
-  * Set **Widget Cache TTL** to a value appropriate for the contents of the widget. +
- +
-=== Uncached widget === +
- +
-The contents will not be cached at all, and will dynamically-generated each time they are displayed on a page. +
- +
-  * Set **Enable ESI** to either `Public` or `Private` (it makes no difference, as long as it's not `Disable`) +
-  * Set **Widget Cache TTL** to `0`. +
- +
-===== ESI and Third Party Plugins ===== +
- +
-Our ESI implementation supports a few other blocks that belong to third-party plugins. For instance, the WooCommerce shopping cart is considered a private ESI block. +
- +
-As we mentioned earlier, with ESI enabled, your site pages are now considered publicly-cacheable,​ because we are able to punch holes for the occasional non-public content. This is true for all native WordPress pages, and for all WooCommerce pages. It is not, however, true with bbPress. +
- +
-A bbPress page contains so many areas of private data, that it's actually much more efficient to consider the entire page to be private. So, that's what we've done. All bbPress pages are considered private. +
- +
-If one of your favorite plugins warrants special consideration,​ please get in touch with us via [[https://​wordpress.org/​support/​plugin/​litespeed-cache|the WordPress plugin support forum]] and let us know. +
  • Admin
  • Last modified: 2017/09/01 15:42
  • by Lisa Clarke