This is an old revision of the document!


Object Cache Support in LSCWP

As of version 1.8, LiteSpeed Cache for WordPress supports Object Cache.

An object cache stores the results of expensive and/or frequent database queries in a way that makes them easy to retrieve, and eliminates the need for repeated access to the database. Object caching greatly reduces the time it takes to retrieve query results.

For example, your WordPress site's options are stored in the database. Site options include things like the site's name and URL. Every time a page is assembled for a visitor, it is necessary to access the database to read the site options. As you can imagine, these repeated queries for the same information represent wasted resources. With an object cache, you can query the database once, and save the results for a set period of time. During that time, whenever a page must be assembled, WordPress can get the site information from the cache. Accessing object cache is a much less resource-intensive prospect than accessing a database.

Some queries are time-consuming, and other queries are repeated frequently. Both of these scenarios can be improved by storing the query results in object cache.

Note: If you have a site that is fully-cached by LSCWP, you won't use object cache very often. Object cache is only necessary when WordPress is building a page through PHP. If PHP is not being invoked (and minimizing PHP usage is the goal with LSCache) then there are no queries to process and therefore nothing to look up in object cache.

LSCWP doesn't provide object caching directly. Rather, it supports your use of an external object cache such as Memcached or LiteSpeed's drop-in Memcached replacement, LSMCD.

Further Reading

If you are using LSMCD or Memcached, you can set up LSCWP support in the Cache Settings tab. Navigate to LiteSpeed Cache > Settings > Cache and scroll down to Object Cache. You will need to give LSCWP some parameters, including where your Memcached or LSMCD lives, which objects you'd like to have cached, and how long you want objects to remain in cache, among other things.

Before enabling Object Cache, the default values with already be filled in for you, like so:

After enabling Object Cache, the LSCache plugin will automatically run both connection testing and Memcached extension detection.

Detailed instructions for all of these settings can be found here.

There are not too many methods to check the Object Cache log, but if you set debug to ON or Admin IP, and view your page source code, you should see something like this at the bottom of the code:

<!-- Object Cache  [total] 5190 [hit_incall] 5056 [hit] 6 [miss_incall] 21 [miss] 107 [set] 171 -->

total is the total number of objects the page requested.

hit_incall is the number of objects that did not hit Memcached but hit the runtime data from above.

hit is the number of objects retrieved from Memcached.

miss_incall is the number of objects not set in runtime. That is to say, when php ran into the current line, no data was set before.

miss is the number of objects not found in Memcached.

set is the number of objects set in Memcached.

If your Connection Test shows Failed like in the following image, there are a few things you can try.

  1. Try service memcached status, to make sure the service is active (running).
  2. Try ss -lptun | grep 11211, to make sure the Memcached port is listening.
  3. Try telnet localhost 11211, to make sure you can connect to localhost successfully.
  • Admin
  • Last modified: 2018/01/23 21:47
  • by Lisa Clarke