Blog · 31 Oct 2026 · 7 min read
How to enable and use LiteSpeed ESI on cPanel hosting
Use ESI to hole‑punch cached pages so cart widgets and small personalized bits stay dynamic. This guide covers server prerequisites, LiteSpeed Cache setup, fragment wiring and common troubleshooting on cPanel.
By Tim Gocelerus
Problem: You want most pages served from cache while keeping small parts (cart widget, admin bar, personalized greeting) dynamic for each visitor.
What ESI is and when to use it
Edge Side Includes (ESI) lets the web server assemble a page from a public cached shell and user‑specific fragments. That means a large portion of the page can be served from cache while small parts are fetched separately (from a private cache or uncached), avoiding PHP for the public portion. Use ESI when most of a page is identical for everyone but a few small elements must remain unique per visitor (cart widget, recently viewed, login/admin bar).
Server prerequisites you must check first
-
The web server must support ESI. OpenLiteSpeed does NOT support ESI. ESI is provided by LiteSpeed Web Server (Enterprise), LiteSpeed Web ADC, or by using QUIC.cloud's ESI features via the CDN. If you are on shared hosting, ask your host or system administrator whether ESI is available for your virtual host.
-
ESI must be enabled in the server's cache engine for your virtual host. If ESI is not enabled at server level, enabling the plugin's ESI option does nothing.
Ask your admin to ensure the virtual host's CacheEngine includes esi. An example configuration (from LiteSpeed docs) looks like this:
<IfModule Litespeed>
CacheEngine on esi crawler
</IfModule>
If esi is missing from the CacheEngine line, the server will not process ESI.
Steps to enable ESI in WordPress on cPanel (overview)
-
Install and activate the LiteSpeed Cache plugin:
- In WordPress admin go to Plugins > Add New.
- Search for "LiteSpeed Cache" and install the plugin named "LiteSpeed Cache".
- Activate the plugin.
-
Verify server support before changing plugin settings:
- Confirm with your host that your virtual host runs LiteSpeed Web Server (not OpenLiteSpeed) and that
esiis enabled in CacheEngine for your vhost.
- Confirm with your host that your virtual host runs LiteSpeed Web Server (not OpenLiteSpeed) and that
-
Enable ESI in the plugin:
- In WordPress admin open the plugin menu: LiteSpeed Cache.
- Open the Cache tab and find the ESI subtab (LiteSpeed Cache > Cache > ESI).
- Switch Enable ESI to ON.
-
Identify the fragments to convert to ESI
- Choose small dynamic pieces: cart widget, user greeting, admin bar, recently viewed list. Keep fragments small and focused: the more self‑contained they are, the easier to cache and the lower the risk of accidental exposure.
-
Provide fragment endpoints or use plugin helpers
- LSCWP can render fragments by pointing an ESI include at a same‑domain URL that returns only the fragment HTML. The server will fetch that URL to assemble the page.
- Common patterns:
- Create a lightweight template or endpoint (PHP script or WordPress endpoint) that outputs only the fragment.
- Insert an ESI include for that endpoint into the page so the server replaces the ESI tag with the fragment output.
Example fallback pattern (PHP):
if ( function_exists( 'litespeed_esi_tag' ) ) {
echo litespeed_esi_tag( site_url( '/esi/cart-fragment.php' ), 0, 'cart' );
} else {
include __DIR__ . '/cart-fragment.php';
}
Note: ESI include URLs must be same‑domain; the server restricts cross‑domain esi:include for security.
Widgets, nonces and private data: practical tips
-
If a fragment must contain a WordPress or WooCommerce nonce (or any per‑request token), generate that token inside the fragment endpoint itself, not in the main cached page. The fragment endpoint runs independently and should produce any fresh nonce or token before output.
-
Keep fragments free of sensitive state that would accidentally be cached publicly. Configure the fragment endpoint so its headers instruct the server how to cache it (private, public with user key, or uncached) according to your needs.
-
For WooCommerce: LiteSpeed Cache includes integration for common WooCommerce fragments (cart fragments, mini cart). When ESI and the plugin's WooCommerce integration are enabled, those handlers may be used automatically; check your theme and plugin code if a cart widget still appears cached.
How to test and debug "ESI doesn't work"
When ESI doesn't behave as expected, use these checks in order:
-
The server processed the ESI tags?
-
Fetch the page HTML as the server returns it and look for raw ESI tags. If you see
<esi:include ...>or a literal ESI comment in the HTML delivered to the browser, the server did not process ESI. Typical causes: serverCacheEnginelacksesi, or you are on OpenLiteSpeed. -
Quick test with curl to get the final HTML:
-
curl -s https://example.com/page | head -n 80
If server side processing happened, you should see the fragment HTML where the ESI tag would be; otherwise you will see an unprocessed ESI tag.
-
The server-level setting is missing or wrong
- If ESI tags remain in the output, contact your host and ask them to confirm the vhost's CacheEngine line includes
esi.
- If ESI tags remain in the output, contact your host and ask them to confirm the vhost's CacheEngine line includes
-
Fragment URL caching behavior
- Check headers for the fragment endpoint itself to ensure it is not being cached publicly in the way you don't expect. Example:
curl -I https://example.com/esi/cart-fragment.php
- Look for cache‑related headers (Cache‑Control, any LiteSpeed cache headers). If the fragment is cached publicly when it should be private, adjust the endpoint to emit appropriate headers.
-
Same‑domain restriction or URL mismatch
- ESI includes must reference same‑domain URLs. If your fragment URL redirects to another domain (or to HTTP vs HTTPS mismatch), the server may refuse to include it.
-
Nonce or session problems
- If the fragment shows stale or invalid nonces, ensure the fragment endpoint generates the nonce for each request and that it is not relying on precomputed tokens from the main page.
-
Plugin config mistakes
- Double‑check LiteSpeed Cache > Cache > ESI is enabled and that any theme or widget code that should output an ESI include is actually doing so.
When to ask for help from your host or a developer
- Ask the host if ESI is not processed at all (server vhost setting). Only a host or sysadmin can enable
esiin the CacheEngine for your virtual host. - Ask a developer if you need to convert a widget or theme element into a fragment endpoint or to change header behavior for the fragment.
Quick checklist before going live
- Confirm server supports and has enabled ESI.
- Enable ESI in LiteSpeed Cache plugin (LiteSpeed Cache > Cache > ESI).
- Ensure fragment endpoints are same‑domain and return the correct cache headers.
- Generate nonces inside fragments, not in the cached shell.
- Test with curl to verify the server replaced ESI tags with fragment HTML.
Closing notes
Edge Side Includes can reduce PHP work and let you keep page cache while serving small dynamic elements per user, but ESI only works if the server supports it and the fragments are implemented correctly. If you need hosting in Southeast Asia, Gocelerus is cPanel web hosting for Indonesia and Cambodia first; servers are in Singapore with NVMe storage, LiteSpeed web server and Imunify360 security, daily backups are included, and moving an existing site to Gocelerus is free (the team does the migration).