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
Last revision Both sides next revision
litespeed_wiki:cache:lscwp:esi [2017/09/01 15:29]
Lisa Clarke [What is ESI?]
litespeed_wiki:cache:lscwp:esi [2017/09/11 16:22]
Lisa Clarke [Enabling ESI from the Web Server or a Virtual Host]
Line 9: Line 9:
  
 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. 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 ===== ===== Public Cache vs. Private Cache =====
  
-LiteSpeed Cache is tag-based (which means that each page is stored with an identifier that allows it to be purged from cache as part of a specific subset) and 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.+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? ===== ===== How do ESI and Public/​Private Cache Work Together? =====
Line 22: Line 24:
 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. 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 a few holes in it for the private content, and save that content in the private cache.+**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 ===== ===== Examples =====
- 
-Let's look at a few common scenarios and see how they play out with ESI enabled and without ESI. 
  
 ==== Example #1: Admin Bar ==== ==== Example #1: Admin Bar ====
  
-You're the site admin, you are logged in, and you visit your site'​s ​home page, which is in the public cache.+logged-in site admin visits the publicly-cached ​home page:
  
-**Without ESI**: ​your 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 your site, for that matter) cannot be served to you from cache.+**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 ​to you from the public cache, while the admin bar is served ​to you from your private cache. There is no need to invoke PHP.+**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 ==== ==== Example #2: Recent Posts Widget ====
  
-You have a large site with much static content that rarely changes. Every page has sidebar, and the sidebar widget ​"​Recent Posts" ​appears ​on each page.+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. **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 nice long TTL, while the Recent Posts widget is the only thing that needs to be purged. Re-populating ​that one bit of the cache requires just one visitor to request any page one time.+**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 =====+===== Enabling ESI from the Web Server or a Virtual Host ===== 
 +Cache and ESI must be enabled on the web server before you can use it. In a shared hosting environment,​ your system admin will control if a specific virtual host account has ''​CacheEngine on/off; esi on/​off''​. Consult your system admin to see if ESI has been enabled for your domain. 
 + 
 +If you are the system admin, see [[litespeed_wiki:​cache:​common_installation:​shared-enable-individually|Enabling Cache for an Individual Virtual Host]] for further instruction. 
 +===== Enabling and Configuring ESI from the LiteSpeed Plugin ​=====
  
 LiteSpeed Cache for WordPress considers all cacheable full-pages to be publicly-cached. LiteSpeed Cache for WordPress considers all cacheable full-pages to be publicly-cached.
Line 59: Line 63:
  
 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. 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.
- 
-**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? It depends on your site, really, and it may require some experimentation on your part. 
  
 ==== Basic ESI Settings ==== ==== Basic ESI Settings ====
Line 76: Line 78:
 Navigate to **WP Admin > Appearance > Widgets** and select the widget that you want to turn into an ESI block. Navigate to **WP Admin > Appearance > Widgets** and select the widget that you want to turn into an ESI block.
  
-Within the widget settings area, you will see a shaded box entitled "​LiteSpeed Cache." ​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, ​there are a few possible ​configurations:​+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 === === Private widget ===
  • Admin
  • Last modified: 2024/03/18 18:42
  • by Lisa Clarke