WpW: Using LSCache with the WordPress CLI
Welcome to another installment of WordPress Wednesday!
Today’s topic is: Using LSCache with the WordPress CLI
WP-CLI is the command-line interface for WordPress. It allows you to perform many actions that would normally require you to visit the WordPress Dashboard in a browser. The following commands are provided by LiteSpeed, so that you may manage your cache with the CLI.
Use ‘lscache-admin’ plus these commands to view and change LSCache’s configuration.
get_optionsallows you to see what options are available:
wp lscache-admin get_options
export_optionssends all of the options to a file:
wp lscache-admin export_options
set_optionallows you to change a particular option to a particular value. (It might be handy to export the options first, so that you know what each option is named, and what type of value is expected.) For example, to configure LSCache not to cache the login page, you would use the following:
wp lscache-admin set_option cache_login false
import_optionsconfigures LSCache according to the options in a specified file:
wp lscache-admin import_options options.txt
lscache-purge plus these commands to purge specific entries from the cache.
network_listdisplays all of the site domains and IDs in a table:
wp lscache-purge network_list
allpurges everything associated with the WordPress installation:
wp lscache-purge all
blogpurges all cache entries for a particular blog ID. For example, in a multisite install, purge only the
shop.example.comcache (stored as blog id
wp lscache-purge blog 2
urlpurges all cache tags related to a particular url. For example, purge the front page and all related tags:
wp lscache-purge url https://mysite.com/
tagpurges the listed WordPress tags by ID. For example, purge the tag IDs
wp lscache-purge tag 1 3 5
categorypurges the listed WordPress categories by ID. For example, purge the category ids
wp lscache-purge category 1 3 5
post_idpurges all cache tags related to the listed WordPress Posts or Products by ID. For example, purge the post ids
wp lscache-purge post_id 1 3 5
Have some of your own ideas for future WordPress Wednesday topics? Leave us a comment!
Don’t forget to meet us back here next week for the next installment. In the meantime, here are a few other things you can do:
- Subscribe to the WordPress Wednesday RSS feed
- Download LiteSpeed Cache for WordPress plugin
- Learn more about the plugin on our website