PHPSESSID cookie on every page, why LiteSpeed Cache is not caching

If a plugin starts a PHP session on every page load, the server sends a PHPSESSID cookie to every new visitor and LiteSpeed Cache cannot serve the same cached page to everyone. You can see it in the response headers, where there is a Set-Cookie: PHPSESSID=... and x-litespeed-cache never turns into hit. The fix is to find the plugin that starts the session and turn off the relevant setting, or replace it.

PHPSESSID is the cookie PHP sends when a script starts a session. With it, the server recognizes the same visitor from page to page and keeps data just for them.

LiteSpeed Cache keeps one shared copy of each page for visitors, the same for everyone. A page that starts a session, however, signals that its content may be different for each visitor. The LiteSpeed Cache documentation states clearly that pages relying on PHP sessions are not cache-friendly, and LiteSpeed treats PHPSESSID as a private session cookie. The result is that every visitor goes through PHP and the database, as if there were no cache.

This behavior is common in plugins for tracking and advertising pixels, forms, pop-ups, multilingual sites or currencies, and in older plugins written before page caching became common. WordPress on its own does not use PHP sessions.

How to see x-litespeed-cache in the response headers

You check this from the browser tools, as a regular visitor. If you are logged in to WordPress, LiteSpeed Cache shows you a different, private cache.

  1. Open a private window in the browser.
  2. Press F12 (on a Mac Cmd + Option + I) to open the Developer Tools and go to the Network tab.
  3. Open a page of the site, for example https://example.gr/, and reload it once or twice.
  4. Click the first line in the list, which is the page itself, and look at the Response Headers.

What the values mean:

Header What it means
x-litespeed-cache: hit The page came from the cache. All good.
x-litespeed-cache: miss The page was not in the cache and has just been cached. On the second reload it should become hit.
x-litespeed-cache-control: no-cache The page was excluded from the cache, by a setting or by a plugin.
set-cookie: PHPSESSID=... A script started a PHP session on this page.

If you see miss on every reload, or no x-litespeed-cache at all, together with a set-cookie containing PHPSESSID, you have found the cause. An x-litespeed-cache miss on every load means something is wrong. Also check two or three other pages, for example a category and a product, because the session may start only on some of them.

For comparison, you can open the page with ?LSCWP_CTRL=NOCACHE at the end of the address. This shows the page without cache, so you can see how much difference caching makes.

How to find which plugin starts the session

  1. Check the settings of the plugins you suspect. Several tracking, form or cart plugins have an option to disable PHP sessions in their general settings. If you find it, enable it.
  2. Deactivate plugins one at a time. After each deactivation click Purge All in LiteSpeed Cache and check the headers from a private window. When the set-cookie with PHPSESSID disappears, you have found the plugin. Do it at low-traffic times, because while a plugin is deactivated its feature is missing.
  3. Check the LiteSpeed Cache debug log. In LiteSpeed Cache > Toolbox > Debug Settings set Debug Log to ON and Debug Level to Advanced. The log records why a page was not cached. Turn debugging off as soon as you finish, because the file grows quickly.

If the plugin has no such option, ask its developer to store the information in a cookie of its own instead of a PHP session. This is also what the LiteSpeed documentation recommends. Otherwise, look for an alternative plugin that works properly with page caching.

What NOT to do with PHPSESSID in LiteSpeed Cache

  • Do not add it to Do Not Cache Cookies. In LiteSpeed Cache > Cache, on the Excludes tab, Do Not Cache Cookies excludes from the cache every page that carries that cookie. Since PHPSESSID is everywhere, you would stop caching across the whole site.
  • Do not add it to Vary Cookies. The Vary Cookies setting on the Advanced tab keeps a separate copy for each value of the cookie. PHPSESSID has a different value for every visitor, so you would end up with one copy per visitor, which means no real caching.
  • Do not try to delete the cookie with code in the theme. The plugin that needs the session will stop working properly, without you noticing right away.

Excluding the plugin's dynamic endpoint

Once you disable PHP sessions, many plugins fetch each visitor's data with a separate request to the WordPress REST API, at an address such as /wp-json/onoma-plugin/.... By default LiteSpeed Cache also caches REST API requests. If the plugin needs a fresh response for each visitor, exclude that path:

  1. Find the address on the Network tab, among the requests the page makes after it loads, or in the plugin's documentation.
  2. Open LiteSpeed Cache > Cache, Excludes tab.
  3. In Do Not Cache URIs enter the path on its own line, for example /wp-json/onoma-plugin/. The exclusion matches every address that contains it.
  4. Save and click Purge All.

You exclude only this small path. The site's pages stay cached.

Plugins that make extra requests on every load

On the same Network tab, check whether the page makes requests it does not need, for example a plugin that checks on every load whether its own CSS file exists, or that calls an external service. Every such request goes through PHP, even when the page itself came from the cache. If you see such a request, check the plugin's settings to see whether it can be turned off, or load the file locally. To see which plugin or external call is slowing things down, use the X-Ray App, which is available on every Konet plan.

How to confirm it is fixed

  1. Click Purge All in LiteSpeed Cache.
  2. Open the page in a new private window and reload it twice.
  3. The response headers should no longer contain a set-cookie with PHPSESSID and x-litespeed-cache should show hit.

With caching working, the server response time drops noticeably and your account uses fewer resources. For the other factors that affect speed see slow WordPress site. For caching at server level see the LiteSpeed Web Cache Manager.

Frequently Asked Questions

LiteSpeed Cache is not caching, how can I tell?
Open the page in a private window, reload twice and check x-litespeed-cache in the response headers. If it never becomes hit, the page is not being served from the cache.

I see Set-Cookie PHPSESSID only on the cart page. Is that a problem?
No. The cart, checkout and customer account are not cached anyway. It is a problem when the cookie appears on the home page, categories and products.

When logged in to WordPress I see different headers from a visitor. Why?
LiteSpeed Cache keeps a separate, private cache for logged-in users. Always run the check logged out, from a private window.

Can Konet remove PHPSESSID on the server?
No. The cookie is requested by the site's plugin and, if the server blocked it, the plugin would work incorrectly. The fix belongs in the plugin itself or its settings. See what hosting support covers.

I disabled PHP sessions in the plugin, will something break?
Plugins that offer this option usually keep working with cookies or REST API requests. After the change, check that the plugin's feature, for example tracking events or a form submission, still works normally.

PHPSESSID came back after a plugin update. Why?
An update can change the plugin's settings or behavior. Check the headers again after every major update. If the update broke other things too, see how to restore WordPress after an update.

Was this article helpful?

Related service Konet Web Hosting cPanel, LiteSpeed and automatic backups: 24 every 2 hours for 48 hours, then 6 daily, 4 weekly and 3 monthly.