WpW: Using LSCache with the WordPress CLI

March 14th, 2018 by LSCache 0 Comments

Using LSCache with the WordPress CLI

Welcome to another installment of WordPress Wednesday!
Today’s topic is: Using LSCache with the WordPress CLI

Disclaimer: The information contained in this post is accurate for LSCWP v2.0 [release log]. If you are using a newer version of the plugin, some details may have changed. Please refer to our wiki for the latest!

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.

Option Commands

Use ‘lscache-admin’ plus these commands to view and change LSCache’s configuration.

  • get_options allows you to see what options are available:
    wp lscache-admin get_options
  • export_options sends all of the options to a file:
    wp lscache-admin export_options
  • set_option allows 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_options configures LSCache according to the options in a specified file:
    wp lscache-admin import_options options.txt

Purge Commands

Use lscache-purge plus these commands to purge specific entries from the cache.

  • network_list displays all of the site domains and IDs in a table:
    wp lscache-purge network_list
  • all purges everything associated with the WordPress installation:
    wp lscache-purge all
  • blog purges all cache entries for a particular blog ID. For example, in a multisite install, purge only the shop.example.com cache (stored as blog id 2):
    wp lscache-purge blog 2
  • url purges 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/
  • tag purges the listed WordPress tags by ID. For example, purge the tag IDs 1, 3, and 5:
    wp lscache-purge tag 1 3 5
  • category purges the listed WordPress categories by ID. For example, purge the category ids 1, 3, and 5:
    wp lscache-purge category 1 3 5
  • post_id purges all cache tags related to the listed WordPress Posts or Products by ID. For example, purge the post ids 1, 3, and 5:
    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:


Categories:LSCache

Related Posts


Comments