I am re-using code I successfully used in a very similar theme and install, and in this new site/environment, the function set_transient does not write the transient to the database, returns false, and I get no errors.

As a test, I've also attempted setting a very simple test transient (set_site_transient('test_transient','test content', 28800);), and that also fails to write to the database. I've isolated it from the larger function, and just tried added it directly to a page template, functions.php, etc., and even the simple test fails to set anywhere else either. There are no errors in the log.

As another test, I replaced set_site_transient() with update_option(), and the option was properly added and set, so the issue is specific to transients.

What factors in the site, install, or perhaps unrelated code, could be causing this to not work?

1 Answer 1


If you have a persistent object cache setup, then transients will not write to the database: they'll be stored in memory. Reviewing the definition of set_transient() this can be seen:

if ( wp_using_ext_object_cache() || wp_installing() ) {
    $result = wp_cache_set( $transient, $value, 'transient', $expiration );

Only if no external cache is in place do transients write to the database.

Try setting a value with set_transient(), and then attempt to recall the value using get_transient(). If you receive the value back, then there's some sort of cache running. If you don't receive the correct value back, then there's something else going on, and will need to dig into set_transient() to see what's going wrong where.

  • This is great to know (and making a note of this). This is not, however, the cause of the issue I'm running into on my local development server with no object cache set up.
    – StudioAl
    Commented Jun 20, 2023 at 18:04
  • ETA: I've just read an explainer on using object cache in a similar way I've been using transients, and it sounds like it may be worthwhile to incorporate caching anyway… thanks for this lead.
    – StudioAl
    Commented Jun 20, 2023 at 18:19
  • If you set a transient, and then attempt to recall it using get_transient(), does that return the expected value?
    – Caleb
    Commented Jun 20, 2023 at 18:21
  • 1
    Updated answer.
    – Caleb
    Commented Jun 20, 2023 at 19:37
  • 1
    Correction! I just found a holdover cache plugin that I accidentally pulled from the production server. The issue was due to object cache. But I think because of the incomplete cache settings from the errant plugin, the object cache wasn't working properly either, so the transient was also not saved in cache. When I removed the caching plugin, the transient again worked again. On the production server, with object cache (but properly set up caching), the transients work correctly as well.
    – StudioAl
    Commented Jun 20, 2023 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.