We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.

Your Digital Commerce Experts
Nexcess Logo

Deleting Expired WordPress Transients & Post Revisions

February 24, 2022


Deleting Expired WordPress Transients & Post Revisions


WordPress management and WordPress maintenance are important aspects of overall site health. Deleting expired WordPress transients/post revisions is vital!

How to Delete Expired Transients & Post Revisions Using WP-CLI

Backup Early, Backup Often

It's always a good idea to have a recent backup...

Before making any change to the settings for your WordPress site, it's always a good idea to have a recent backupIf your WordPress site or WooCommerce portal is running on one of our managed WordPress hosting plans, you know one aspect of WordPress management that we handle for you is automatic daily backups of your content and data. However, since the most recent daily backup may have been performed hours and hours ago, please create a manual backup using your managed WordPress portal or using the WordPress Command Line Interface (WP-CLI) from inside the terminal.

Using WP-CLI to Perform a Manual Backup

Since we'll be in a terminal session today using WP-CLI already, let's create a quick backup from the command line.

First, after you've opened a Secure Shell (SSH) connection to your server, let's make sure our working directory is the directory of our WordPress installation. In this example, our WordPress site is located in the default site document root, public_html.

[wpclitesting@host ~]$ cd public_html/

[wpclitesting@host public_html]$ ls
Error_log           wp-config-sample.php    wp-login.php

Index.php           wp-config.php           wp-mail.php

Readme.html         wp-content              wp-settings.php

Wp-activate.php     wp-cron.php             wp-signup.php

Wp-admin            wp-includes             wp-trackback.php

wp-blog-header.php  wp-links-opml.php       xmlrpc.php


We can see the WordPress configuration files, so we know we're in the right place.

Next, we'll run a quick backup of our WordPress database:

[wpclitesting@host public_html]$ wp db export ../wp-cli-testing-20220114.sql
Success: Exported to 
'../wp-cli-testing-20220114.sql'.


WordPress Transients — Why Should We Remove Expired Transients

WordPress intends for transients to be used for short-term caching of data inside the WordPress database. However, WordPress does not automatically delete expired transients. Instead, the creator of an expired WordPress transient (almost always a plugin) is expected to handle that aspect of WordPress maintenance. But some plugins that use transients do not always remove their respective transients after they expire. Over the span of months and years, these expired-but-not-deleted transients living inside the wp_options table of the database can begin to slow things down and impede site performance. For this reason, we should remove expired transients to improve WordPress site performance.

WordPress Transients — A Closer Look

Let's make sure our version of WordPress supports transients.

[wpclitesting@host public_html]$ wp core version
5.1.6


In this example, we're


In this example, we're running with WordPress Version 5.1.6, first released in mid-2020. Because WordPress has supported transients since WordPress Cersion 2.8, our version is recent enough to have the supported transients included.

Though recent enough to have transients, our version in this example is slightly outdated and should be updated to a more recent version. See our blog post, WordPress Updates: How To Install an Update Safely, for a good guide on updating core WordPress.

And here are the transients in our example WordPress site:

[wpclitesting@host public_html]$ wp transient list

+---------------------------------------------+----------------------------------------------+------------+

| name                                        | value                                         | expiration |

+---------------------------------------------+----------------------------------------------+------------+

| jetpack_akismet_key_is_valid                | valid                                         | 1641913553 |

| jetpack_idc_allowed                         | 1                                             | 1641866392 | *

| jetpack_plugin_api_action_links_refresh     | 1641532868                                    | 1641845488 | *

| jetpack_sync_constants_await                | 1641536958.2617                               | 1641913553 |

| jetpack_sync_last_checked_queue_state_sync  | a:2:{i:0;i:0;i:1;i:0;}                        | 1641912144 |

| slimstat_visit_id                           | 1299                                          | false      |  

| update_plugins                              | O:8:"stdClass":1:{s:12:"last_checked";i:0;}   | false      |

| update_themes                               | O:8:"stdClass":1:{s:12:"last_checked";i:0;}   | false      |

| twentyseventeen_categories                  | 2                                             | false      |

| wpcom_social_media_icons_widget::is_active  | 0                                             | 1641835570 | *

+---------------------------------------------+----------------------------------------------+------------+


As mentioned earlier, WordPress transients are not automatically deleted after expiration, so your list of transients may have more entries than this example list. However, from our example list above, you can see transients with expiration dates (the ones with a number) and ones without expiration dates (the ones labeled 'false').

The expiration value is time in seconds since midnight, January 1, 1970. For example, the transient named jetpack_akismet_key_is_valid has an expiration of 1641913553, which correlates to 2022-Jan-11 09:05:53am.

If you're having caching or performance issues related to a specific transient, you can delete a specific transient by referencing the name:

[wpclitesting@host public_html]$ wp transient delete jetpack_akismet_key_is_valid
Success: Transient deleted.

Rather than remove each expired transient individually by name, we can tell WordPress to delete every expired transient quickly.

[wpclitesting@host public_html]$ wp transient delete --expired
Success: 3 expired transients deleted from the database.


WordPress Post Revisions — Why Should We Remove Post Revisions?

One potential source of WordPress database bloat is post revisions. When you have a post open in the editor, the default setting has WordPress automatically create an auto-save revision every sixty seconds. Though post revisions will not slow down site performance (the WordPress front end only looks at posts of types post and attachment, never revision), it can eat up valuable disk space due to the increased database size.

Here are the posts from our example WordPress installation:

[wpclitesting@host public_html]$  wp post list

+-----+-----------------------------------------+--------------------------------------+---------------------+-------------+

| ID  | post_title                              | post_name                            | post_date           | post_status |

+-----+-----------------------------------------+--------------------------------------+---------------------+-------------+

| 44  | WP-CLI, Transients, Revisions, and You  | deleting-expired-transients-revisons | 2022-01-06 23:32:49 | publish     |

| 21  | WordPress upgrades using WP-CLI         | wp-cli-upgrade                       | 2020-08-21 20:54:38 | publish     |

| 10  | How To Delete Post Revisions using WP-  | delete-post-revisions-using-wp-cli   | 2019-06-19 09:11:21 | publish     |

| 6   | First post!                             | test-post-1                          | 2019-06-14 12:36:34 | publish     |

+-----+-----------------------------------------+--------------------------------------+---------------------+-------------+


And here are the post revisions:

[wpclitesting@host public_html]$  wp post list --post_type='revision'

+-----+-------------------------------------------+-----------------------------------------+---------------------+-------------+
| ID | post_title | post_name       | post_date           | post_status |  
+-----+-------------------------------------------+-----------------------------------------+---------------------+-------------+

| 48  | WP-CLI, Transients, Revisions, and You    | deleting-expired-transients-revisons    | 2022-01-06 23:00:54 | publish     |

| 23  | WordPress upgrades using WP-CLI           | wp-cli-upgrade                          | 2020-08-21 20:23:21 | publish     |

| 22  | WordPress upgrades using WP-CLI           | wp-cli-upgrade                          | 2020-08-21 19:36:33 | publish     |

| 20  | How To Delete Post Revisions using WP-CLI | delete-post-revisions-using-wp-cli-revi | 2019-06-29 09:09:24 | publish     |

| 18  | How To Delete Post Revisions using WP-CLI | delete-post-revisions-using-wp-cli-revi | 2019-06-29 09:08:15 | publish     |

| 13  | How To Delete Post Revisions using WP-CLI | delete-post-revisions-using-wp-cli-revi | 2019-06-29 09:07:39 | publish     |

| 14  | How To Delete Post Revisions using WP-CLI | delete-post-revisions-using-wp-cli-revi | 2019-06-29 09:04:34 | publish     |

| 12  | How To Delete Post Revisions using WP-CLI | delete-post-revisions-using-wp-cli-revi | 2019-06-29 09:03:29 | publish     |

+-----+-------------------------------------------+-----------------------------------------+---------------------+-------------+


Though we could delete the revisions one by one, using the ID, this would become an unwieldy task.

This one-liner comes to the rescue by quickly deleting every past revision for all posts:

[wpclitesting@host public_html]$  wp post delete $(wp post list --post_type='revision' --format=ids) --force


And that’s all there is to it! For older or more active WordPress sites, removing all post revisions can quickly reduce the size of the database by two-thirds.

Further Reading for Performance Tuning WordPress

In addition to the increase in site performance by regular WordPress maintenance of WordPress transients, you can see an increase in site performance by:



You can find answers to your other WordPress questions in our Nexcess Knowledge Base.


Useful WordPress Links for Developers & Admins

Consider Hosting with Nexcess


Hosting optimized for the industry's leading platforms, including Managed WordPress Hosting, Managed WooCommerce Hosting, and Managed Magento Hosting:

Build Better Sites and Stores With Fully Managed Hosting from Nexcess 

Faster Speeds, Stronger Security, Inherent Scalability and Trusted Support.

Our range of hosting plans caters to any business scale. We do all the heavy lifting for you to focus on growing your business. In addition, we automatically update ore components and plugins to the latest version and ensure your hosting environment is properly optimized, secured, and updated.


Nexcess infrastructure was specially designed to keep up the best speed and performance in the industry. No traffic surge can threaten your website to go down thanks to our autoscaling technology which adds more resources to your server to handle the load. In addition, we offer always-on security monitoring and support from web hosting experts 24/7/365 and a built-in CDN with 22 locations and advanced caching for ultra-fast loading.


All hosting plans include The Nexcess 30-Day Web Hosting Money Back Guarantee.


Need a No-Code Website Building Solution? 


Are you on an accelerated schedule and already ready to move forward? If you need to get started with your Nexcess StoreBuilder Solution sooner rather than later, check out these resources:


Next Steps with a Nexcess Cloud Hosting Solution?

Read more about the Fully Managed Cloud Environment by Nexcess and its benefits for your business.

A Cloud Hosting Solution That Lets You Do Business Your Way 

We believe in the promise of cloud: scalability, security, performance, and ease of use. Together with our team, clients, and partners, we’ve built something better.

Choose From Multiple Applications 

Whether you’re a small business or a high-traffic eCommerce store, our cloud hosting solutions are designed around your needs: auto scaling, PCI compliance, and comprehensive development tools provide you with maximum dynamic flexibility in a fully managed cloud environment.


We make applications easy with environment optimizations for:


And there are many more!


Next Steps with Fully Managed WordPress Hosting?

Read more about the Fully Managed WordPress Hosting and its benefits for your business.

Build Better Websites with Fully Managed WordPress Hosting 

It’s hosting optimized for WordPress. That means a faster, more secure and scalable website. Smart monitoring tools are built-in to help you keep it that way. 

It’s why WordPress Users Trust Nexcess Hosting.

We also have a variety of Nexcess support articles about WordPressincluding how to get your site going with a number of different configuration options. These resources include a great article on setting this up for migrating to Nexcess with managed WordPress and managed WooCommerce hosting

Considering Use of a CDN?

Many businesspeople wonder how a CDN speeds up your ecommerce site, but they will discover that the reasons are remarkably straightforward. Review the content, resources, and links in this article to learn more about those reasons in full detail.  

24-Hour Assistance

If you need any assistance with the above-mentioned, don't hesitate to reach out. For 24-hour assistance any day of the year, Nexcess customers can contact our support team by email or through your Client Portal.

Why Choose Nexcess?

Because we're different! Chris Lema captures "the why" in his passionate and stirring recount of a Nexcess support-related story.



Useful YouTube > Nexcess Channel Links

Resources for More Information

Need more help? The Applications, WooCommerceand WordPress sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge. 

The Applications section also contains valuable insights for those seeking additional knowledge about our other various hosted applications and platforms. Check out our related video playlists and articles below:

New Customers: Fully Managed Hosting Solutions

Not a Nexcess customer yet? Check out our fully managed hosting solutions. The option to chat with an expert is also available.

Related Articles

Paul Stubblefield
Paul Stubblefield


Nexcess Knowledge Base Owner
Content Marketing in Nexcess Digital Marketing
Nexcess, A Liquid Web Brand

Paul Stubblefield
— Technical Writer & Knowledge Management Professional

"Delivering the next generation of life-enhancing technology platforms, software solutions, and mobile-ready applications for technology pioneers, thought leaders, and market innovators in a robustly connected world."

Paul lives in Bonita Springs, Florida, USA. He is an aficionado of art, coffee, good-natured humor, lifelong learning, music, nature, pets, technology, world cultures, and his Zen Patio Garden project.