You are using transient API which works storing data on wp_options
table by default. That means that additional database queries will be performed to set the transient and to get the transient. With your code the number of queries should be less for non-logged in users in second and subsequent visits when the transient exists and it is valid.
If you use a persistent cache plugin (or you configure persistent cache at your own) the transient API will use WP_Object_Cache allowing the cached data be stored in memory instead of database, so there won’t be extra database queries.
Summary: using wp_cache functions will store cached data on memory and it is not persistent by default. In the other hand, transient API is persistent always and it use database by default. If you configure persistent cache, transient API and WP_Object_Cache return same results as transient API will use WP_Object_Cache.
Related Posts:
- Should I use Transient API to store HTML String, or Object?
- Using a wildcard with delete_transient()
- How to purge all transient caches?
- Transient / object cache maximum key length [duplicate]
- How to purge all transient caches?
- Transients are not expiring as expected in simple custom plugin
- How to store or cache custom shopping cart data for every user’s session
- How to decode wordpress transient cache stored in database?
- Hook an action when a transient is deleted ? Can’t get it to work!
- After having installed APC Object Cache Backend transients stopped working
- Should I use transients for these API call results?
- How to create a transient that persists the data for the whole duration of the expiration, even when object cache is enabled?
- Best way to show Dynamic Content on a Cached WordPress Site?
- Is define(‘WP_CACHE’, true) needed for object caching?
- Prevent WordPress from sending Cache-control http header
- Optimize apache for WP use
- Is get_option() faster than accessing get_transient()?
- Multiple WordPress sites eat up alot of RAM
- What exactly is an advanced object cache?
- wp_cache_set() or wp_cache_add()
- WordPress transients for a shortcode
- Which WordPress pages/URLs should never be cached?
- How to archive a wordpress site (make it read only)
- Stale cache handling with a persistent object cache
- Is priming a Transient Cache possible?
- Varnish + W3 Total Page Cache [closed]
- Are there any server requirements for WordPress transients to work properly?
- W3 Total Cache doesn’t detect memcached [closed]
- can’t see live version of style.css – is it web server caching?
- Want to enforce the visitor to load the new version of your stylesheets and scripts [closed]
- Speed up WordPress
- wp-super-cache exclude file from caching
- Transients API and multisite
- Possible to configure nginx to ignore cache for logged in users in certain roles only?
- Check if a user is connected and get is ID without fully loading wordpress
- Should I enable FastCGI on WordPress?
- Will caching WordPress affect session variables, custom filed updates and displaying images from a non wordpress table?
- Automatically enabled caching in some hosting companies w/o visible plugin (Must use plugin)
- WordPress Caching – Transients API or “update_user_meta ” Cronjob?
- server load. $_SERVER[‘REMOTE_ADDR’] and $_SERVER[‘HTTP_HOST’] [closed]
- Optimizing Jetpack for WordPress [closed]
- Is it possible to save an entire piece of rendered HTML in a transient?
- Execute a piece of code also when the cached version of a page is served
- Can a WordPress blog be entirely hosted on a CDN if cached?
- Transient feeds and caching error
- Transient loop issue
- To have WordPress interact with memcached it must be installed as a PHP extension?
- Prevent installation of style.css cookies and file caching
- How can I revert to showing cached pages when no database connection is available? [closed]
- How to speed up my site [duplicate]
- Headway body classes and W3TC page cache conflict [closed]
- Reasonable Size Limit to options entry
- Is the object cached?
- How can I cache the LearnDash quizzes on my server?
- WP_Object_Cache for heavy WP_Query
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- WordPress PHP 5.5 and OPcache
- wp_options flooded with transient API entires
- Batcache messages no longer in page source
- Accelerate and clean up WordPress [closed]
- How to make page/post password protected so you must reenter everytime you visit the page?
- Fixed version number for cached stylesheets and javascript
- How effective are cacheing plugins for dynamic pages?
- Transient api Caches confused
- How can I permanently cache or “archive” a WP blog without needing future maintenance
- How does WP’s cache maintain persistence through page reloads?
- Any idea why Google not caching my site? [closed]
- Gravity forms / Recaptcha / Autoptimize – somewhere it goes wrong
- Using Transients
- Last-Modified header support doesnât speed up server processing – want more
- How to get Caching Plug-ins to work on localhost with HTTPS?
- Cloud flare, cache, minify question [closed]
- HIgh CPU usage – Will using cache plugins help
- Jetpack stats and caching strategy [closed]
- How do I serve fully cached full HTML on cloudfront
- Get user name and caching system
- How to get the URL of a sitemap that contains a certain post?
- How to solve simple wp simple ajax chat caching problem
- dynamic page not displaying correctly when Varnish hosting ignores query string parameters
- How to not cache nonces with WP Rocket?
- Password Protected Pages Don’t Accept A Valid Password After Changing The Password
- What do I do if my WordPress site is suddenly sanitizing portions of URLs it shouldn’t?
- Check the stored / cached WP_Query with transients on post change
- Clear cache when comment is added
- Way to prevent snippet of template from being cached?
- How to make login / logout links cache independent?
- Non Admins Getting Cached Posts
- Why WordPress cache is not available after reload page?
- custom php file inside my custom folder of plugins directory is not caching
- w3 total cache uninstall remove cache
- Completely reload style.css
- Serve content from centralized location
- User cannot authenticate after signup when object cache enabled
- W3 Total Cache Minification: way to revert back? [closed]
- After Migration, Warning: include_once() errors on all pages
- Server Variables not recognized in certain posts
- Experiencing a weird caching issues without any caching plugins
- How I define max cache time to Google Fonts installed on my site
- Keeping Objects in Memory
- How can I wordpress cache a database request with no existing plugin?