Tuesday, January 31, 2023

How to Delete Transients in WordPress

- Advertisement -

Delete Transients in WordPress

WordPress plugins and themes can store a lot of temporary data known as transients. By default, these transients are stored in the wp_options table and can accumulate rather quickly. Due to an idiosyncrasy in WordPress core, expired transients are only removed from the database if access to them is attempted, if no access to them is made then the transients stay in the wp_options table. This tutorial will show you how to delete expired transients using WP-CLI from wp_options or your external object cache and automate the deletion of these transients every day using a cronjob.

What are transients in WordPress

Delete the value of a network site transient. On a single site, this is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).

WordPress theme and plugin developers make use of these transients to store timely data to increase speed and efficiency. For instance, a plugin or theme may want to check for updates every 24 hours. Once checked, this data is stored as a transient so that the plugin or theme doesn’t make another request every time the page loads.

The good thing is that this transient data will automatically expire at set periods. However, sometimes these transients may quickly pile up and you may not see some changes you made right away. Moreover, the piled-up transients may also increase the database size.

WordPress Transients API offers a simple and standardized way of storing cached data in the database. It is also possible to use APC or Memcached to store the transients, thus increasing the overall performance of a WordPress site. When we do so, the existing transients are not removed from the database. The following commands help to do just that.

Code to Delete Transients

DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient_%');
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_site_transient_%');

To increase performance, WordPress plugins may use the transients API to store some data in the database. While this does increase performance, some old data can be left by disabled or removed plugins that can adversely affect performance. In this article, we will show you how to remove expired transients from your WordPress database.

Aasim Sheikh
Aasim Sheikhhttps://syncsas.com/
CTO at SyncSaS Technologies

Stay in Touch

To follow the best weight loss journeys, success stories and inspirational interviews with the industry's top coaches and specialists. Start changing your life today!

Related Articles

Enable Notifications OK No thanks