WordPress transients are temporary cache entries for data that can be regenerated. You store a value under a key with a maximum lifetime, read it on later requests, and rebuild it when the entry is missing or expired. Because WordPress may keep the value in the database or an external object cache, reliable code always treats a transient as optional rather than permanent storage.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
What a WordPress transient is
A transient is a small, named cache record managed through WordPress’s Transients API. It is designed for results that are expensive to produce but safe to recreate: a slow database query, a rendered fragment, a remote API response, or a calculated summary. The transient key identifies the record, the value contains the cached result, and the expiration argument defines the latest time WordPress should retain it.
As an Amazon Associate I earn from qualifying purchases.
Transients are not a source of truth. Your post data, settings, taxonomy terms, or remote service remain authoritative. A transient only accelerates access to a derived value. If it disappears immediately after being written, your application must still be able to obtain the value again.
The cache-aside pattern
The normal flow is called cache-aside: read first, calculate on a miss, then save the result. The strict comparison with false is important because a legitimate cached value can be zero, an empty string, an empty array, or another falsey value.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
<?php
$key = 'my_plugin_result';
$value = get_transient( $key );
if ( false === $value ) {
$value = expensive_calculation_or_remote_request();
set_transient( $key, $value, HOUR_IN_SECONDS );
}
return $value;
When get_transient() returns false, the key is either absent or no longer available. Your miss path should regenerate a complete, usable value before returning it. If the regeneration fails, handle that failure explicitly instead of caching an invalid response as though it were successful.
How expiration really works
The expiration supplied to set_transient() is a maximum lifetime, not a promise that the record will survive until that time. Ryan McCue, quoted in the WordPress Transients API documentation, explains that a transient may disappear one second after it is set or remain until the stated limit, but it will never be available beyond that expiration time.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchThis has two practical consequences:
- Every read must be prepared for an early miss, even when the nominal lifetime has not elapsed.
- Expiration cannot replace invalidation when you know the underlying data changed.
Use a strict identity check rather than a truthiness check:
<?php
$result = get_transient( 'my_plugin_count' );
if ( false === $result ) {
$result = 0; // Zero is a valid result, so it must not be treated as a miss.
set_transient( 'my_plugin_count', $result, MINUTE_IN_SECONDS );
}
If your application genuinely needs to cache Boolean false, wrap it in another value so that the API’s miss sentinel is unambiguous:
<?php
set_transient( 'my_plugin_flag', array( 'value' => false ), HOUR_IN_SECONDS );
$cached = get_transient( 'my_plugin_flag' );
if ( false === $cached ) {
// Rebuild the cache entry.
} else {
$flag = $cached['value'];
}
The three core functions
set_transient()
set_transient( $transient, $value, $expiration ) accepts a key, a scalar, array, or object, and an expiration in seconds. WordPress serializes arrays and objects for storage, so the value you receive from get_transient() is reconstructed as the corresponding PHP type.
Readable time constants make intent obvious and prevent arithmetic mistakes:
Free tools Windows power users keep installed
One-click scans. No signup required.
MINUTE_IN_SECONDSfor short-lived calculations.HOUR_IN_SECONDSfor results that can remain fresh for roughly an hour.DAY_IN_SECONDSfor daily data.WEEK_IN_SECONDSfor infrequently changing material.
Pass an integer number of seconds or one of these constants. The chosen value is a maximum; it does not guarantee a minimum age.
get_transient()
get_transient( $transient ) returns the stored value or Boolean false when the entry is missing or expired. Always use === false for the miss test. A key that has expired in the database-backed implementation can be removed when it is read, so a miss also helps clean up that individual record.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
delete_transient()
delete_transient( $transient ) removes a value before its maximum lifetime. Call it when an event makes the cached result stale: saving source content, changing a relevant setting, updating taxonomy data, or changing the version of the query that produced the result.
<?php
function my_plugin_clear_result_cache() {
delete_transient( 'my_plugin_result' );
}
// Attach this callback to the action that changes the source data.
add_action( 'save_post', 'my_plugin_clear_result_cache' );
Choose an invalidation hook that actually represents the inputs used by your calculation. Clearing on every save may be correct for a site-wide result, while an object-specific result should delete only the affected key.
Designing transient keys
For database-backed transients, the documented key limit is 172 characters. Keep keys short enough to remain valid even after adding identifiers. A stable, plugin-specific prefix prevents collisions with other code.
Include every dimension that changes the result. Common dimensions are an object ID, locale, user-facing mode, taxonomy ID, or query version:
<?php
$key = sprintf(
'my_plugin_v2_product_%d_%s',
$product_id,
sanitize_key( $locale )
);
A version segment gives you a cheap migration path. If the calculation changes, increment v2 to v3 and old entries become unreachable without a potentially expensive site-wide deletion.
Do not build a key from unbounded input. Normalize values, cap their length, and make sure equivalent requests produce the same key. Before investigating storage, verify that the string passed to set_transient() is byte-for-byte identical to the one passed to get_transient().
Where transients are stored
Without a persistent object-cache drop-in, WordPress commonly stores transients in the wp_options table. The exact database table prefix can differ from wp_, but the important point is that the API abstracts the location.
When a persistent object cache is active, WordPress can route transient operations through an external cache such as Redis or Memcached. Your PHP calls do not change, but persistence, latency, eviction behavior, and capacity can. Do not assume that seeing no row in wp_options means the transient was never set; check whether an object-cache drop-in is handling it.
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Storage choice also affects operational behavior. A database-backed transient may be serialized into an option, while an external cache may evict it for capacity reasons. Both situations are normal cache misses, not data-loss emergencies, provided your regeneration path works.
Autoload and no-expiration entries
Non-expiring transients can be autoloaded. Avoid using a no-expiration transient for data that is not needed on every request, because loading unnecessary values increases the work required to bootstrap a request. If a value has a meaningful freshness window, give it an expiration and let normal cache rules apply.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →A complete implementation pattern
The following example caches a remote response, validates the response before storing it, and deletes the entry when a setting changes.
<?php
function my_plugin_remote_items() {
$key = 'my_plugin_items_v1';
$cached = get_transient( $key );
if ( false !== $cached ) {
return $cached;
}
$response = wp_remote_get( 'https://api.example.test/items' );
if ( is_wp_error( $response ) ) {
return array();
}
$status = wp_remote_retrieve_response_code( $response );
if ( 200 !== $status ) {
return array();
}
$body = wp_remote_retrieve_body( $response );
$items = json_decode( $body, true );
if ( ! is_array( $items ) ) {
return array();
}
set_transient( $key, $items, HOUR_IN_SECONDS );
return $items;
}
function my_plugin_settings_changed() {
delete_transient( 'my_plugin_items_v1' );
}
The URL above is only an example endpoint. In production, use your actual service and apply its authentication, timeout, and rate-limit requirements. The transient should contain the normalized data your templates need, not an object that cannot be recreated.
Rendered fragments
A transient can hold rendered HTML when the underlying fragment is expensive to build. Include every output-affecting dimension in the key, such as the page section, locale, and content version. If the fragment contains personalized data, do not share one key across users; either include the relevant user dimension or avoid caching that fragment.
Expensive database queries
Cache the final result of a query when it is safe to reuse. Store the smallest structure that lets the caller render the response. Because complex values are serialized, very large arrays increase serialization and transfer work and can make invalidation harder to reason about.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsInvalidation: do not wait for the timeout
Expiration provides eventual regeneration, but it cannot know when your source data changed. Explicitly call delete_transient() at the event that makes the result stale.
- After saving or deleting the posts included in a cached listing.
- After changing a setting used by the calculation.
- After updating taxonomy data used to filter the result.
- After deploying a new calculation, unless a versioned key already isolates it.
For per-object caches, derive the key from the object identifier and invalidate only that object. For aggregate caches, clear the aggregate key whenever any contributing object changes. If a write operation can affect several keys, keep the invalidation list in one function so future changes do not leave a stale variant behind.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Handling concurrent cache misses
On a busy site, several requests can observe a miss at the same time and all perform the expensive rebuild. The Transients API does not turn the regeneration function into a universal lock. Keep the rebuild safe to run more than once, and consider a short-lived coordination or lock mechanism when the calculation is costly enough that duplicate work would overload a database or remote service.
Regardless of the coordination strategy, retain a fallback path. A lock that expires or disappears must not prevent a later request from rebuilding the value. Treat lock state as temporary cache data, just like the result itself.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Multisite and network-wide values
In WordPress Multisite, ordinary transients are associated with the current site. For one value shared across the network, use the site-transient equivalents:
set_site_transient()get_site_transient()delete_site_transient()
Use site transients deliberately. A locale, setting, or content difference that varies by site belongs in a site-specific key or an ordinary transient. A network-wide key is appropriate only when every site should read the same value.
Cleaning up expired entries
WordPress may clean expired database transients infrequently. Reading an expired entry can remove that entry, but unused records can remain until cleanup runs. During maintenance, inspect and delete entries with WP-CLI:
wp transient list
wp transient get my_plugin_result
wp transient delete my_plugin_result
wp transient delete --expired
Use the network-aware option when working with site transients in a Multisite installation. Run inspection commands in the environment whose object-cache configuration you are diagnosing; a command against the database alone may not reveal values held by an external cache.
Transients compared with the object-cache API
Both APIs can avoid repeating expensive work, but they have different guarantees. The default WordPress object cache is request-local. A persistent object-cache drop-in changes that behavior, whereas transient calls are designed to remain the same across either backend.
| Characteristic | Transients | wp_cache_set() and wp_cache_get() |
|---|---|---|
| Persistence across requests | Designed for reuse across requests; actual retention depends on the database or persistent object-cache backend. | Request-local by default; a persistent object-cache drop-in changes this behavior. |
| Expiration semantics | Expiration is a maximum lifetime, and entries can disappear earlier. | Depends on the object-cache implementation and its configuration. |
| Storage backend | Database-backed in common installations or an external cache such as Redis or Memcached when a persistent drop-in is active. | WordPress’s object-cache backend; persistence requires a drop-in. |
| Invalidation control | Use delete_transient() or the site-transient equivalent. |
Use the corresponding object-cache deletion function and backend behavior. |
| Data shape | Scalar, array, and object values are serialized for storage under a key. | Key/value cache API; storage and serialization details depend on the backend. |
| Multisite scope | Use site-transient functions for a network-wide value. | Scope depends on the cache group and object-cache configuration. |
| Operational tooling | WP-CLI provides wp transient inspection and deletion commands. |
Operational commands depend on the installed object-cache implementation. |
Choose transients when you need a WordPress-standard, expiring value that may survive across requests without tying your code to one cache vendor. Choose the object-cache API when request-local or backend-specific cache behavior is intentional and you control the persistence configuration.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Diagnosing a missing or ineffective transient
The value is always a miss
- Log or inspect the key at both the write and read sites and compare them exactly.
- Check that the key is below the documented 172-character database limit.
- Confirm that the code reaches
set_transient()and that the value is not being deleted by an invalidation hook immediately afterward. - Check whether a persistent object-cache drop-in is active before looking only in
wp_options.
The value disappears before the expected time
That behavior is allowed: expiration is a maximum, not a minimum. External caches can also evict entries. Make the miss path cheap enough to run again and avoid treating early disappearance as corruption.
Valid zero or empty values trigger regeneration
Replace a truthiness check such as if ( ! $value ) with if ( false === $value ). If the valid result is Boolean false, wrap it in an array or use another unambiguous representation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Fresh data is not appearing
Inspect the event that should invalidate the key. Verify that saves, setting updates, and taxonomy changes call the matching deletion function and that every key variant is covered. A longer expiration cannot fix an incomplete invalidation rule.
Database growth is unexpected
Review no-expiration transients first, especially values that are not required on every request. Use WP-CLI to list and delete expired entries, then check whether a persistent cache is handling new writes outside the database.
Operational and security considerations
Never use a transient as the only copy of irreplaceable information. A cache flush, eviction, deployment, or early expiration must be recoverable. Keep credentials, private tokens, and user-specific secrets out of shared keys unless the access boundary is explicit and the value is protected appropriately.
Cache the result after validating the response that produced it. For remote services, distinguish transport errors, non-success status codes, and malformed payloads so a temporary failure does not become a long-lived “successful” cache entry. If stale data is preferable to an outage, document that choice and use a bounded lifetime.
Recommended Free Tools
Performance gains are workload-dependent. There is no universal speedup percentage: database cost, serialization, invalidation frequency, payload size, and object-cache configuration all influence the result. Measure your own hit and miss paths rather than quoting a generic benchmark.
Quick Recap
A deployment checklist
- Define the source of truth and confirm the cached value can be regenerated.
- Choose a short, unique key with all result-changing dimensions and a version segment where useful.
- Set a documented lifetime with a WordPress time constant.
- Read with
get_transient()and test misses using=== false. - Validate and normalize the rebuilt value before calling
set_transient(). - Add explicit invalidation for source-data and configuration changes.
- Test with and without a persistent object-cache drop-in.
- Exercise early misses, expired reads, empty results, and regeneration failures.
- Use WP-CLI to inspect and remove entries during maintenance.
- For Multisite, decide explicitly whether the value is site-specific or network-wide.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




