Terme informatique

WordPress Transients

A mechanism WordPress temporary storage of data with expiry.

⌚ About 2 min read
View my favorites

Simple definition

WordPress transients temporarily store a value with an expiration time so data does not need to be recomputed or fetched on every request.

Technical definition

The Transients API includes functions such as set_transient(), get_transient(), and delete_transient(). Depending on the environment, values can be stored in the WordPress database or handled by a persistent object cache.

How it works / role

A plugin creates a value with an expiration. Subsequent reads reuse it while it exists; after expiration or cache eviction, the code must be able to rebuild it. A transient must therefore not be treated as guaranteed permanent storage.

What is it used for?

Cache expensive results, API responses, calculations, or intermediate data for a limited period.

Practical example

A plugin stores the result of an external request for fifteen minutes; when the transient is no longer available, it calls the service again and recreates the cache.

Common issues

  • A stale transient remains after a configuration change
  • Large amounts of temporary data increase database load without an object cache
  • Code incorrectly assumes the transient will always exist until expiration
  • Object cache and database behavior differs between environments

Key takeaway: A transient is temporary, evictable cache data; application code must always handle a missing value.

♡ 0