0
0
Wordpressframework~20 mins

Caching strategies in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Caching Mastery in WordPress
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main benefit of using object caching in WordPress?
Object caching stores database query results in memory to speed up repeated queries. What is the main benefit of this approach?
AIt creates backups of the WordPress database daily.
BIt reduces the number of database queries, improving site speed.
CIt compresses images to reduce page load time.
DIt automatically updates all plugins to the latest version.
Attempts:
2 left
💡 Hint

Think about what happens when the same data is requested multiple times.

component_behavior
intermediate
2:00remaining
What happens when you enable page caching in WordPress?
Page caching saves the full HTML output of pages. What is the effect on the user experience when page caching is enabled?
AThe site disables all plugins to improve speed.
BUsers see a login screen every time they visit the site.
CPages load faster because the server sends stored HTML instead of generating it each time.
DImages are automatically resized to smaller versions.
Attempts:
2 left
💡 Hint

Think about what happens when the server doesn't have to build the page from scratch.

📝 Syntax
advanced
2:00remaining
Which code snippet correctly sets a transient cache in WordPress?
Select the code that sets a transient named 'my_data' with value '123' that expires in 1 hour.
Aset_transient('my_data', 123, 60*60);
Bset_transient('my_data', 123, 3600);
Cset_transient('my_data', '123', 60);
Dset_transient('my_data', 123);
Attempts:
2 left
💡 Hint

The expiration time is in seconds. 1 hour = 3600 seconds.

🔧 Debug
advanced
2:00remaining
Why does this WordPress transient never expire?
Code snippet:
set_transient('cache_key', 'value', 0);
What is the reason the transient never expires?
Wordpress
set_transient('cache_key', 'value', 0);
ABecause set_transient requires a minimum expiration of 60 seconds.
BBecause the transient key is invalid and ignored.
CBecause the value 'value' is not serializable.
DBecause expiration time 0 means the transient never expires.
Attempts:
2 left
💡 Hint

Check what the expiration parameter means when set to zero.

state_output
expert
3:00remaining
What is the output of this WordPress code using object cache?
Consider this code run in sequence:
wp_cache_set('key', 'first');
$value1 = wp_cache_get('key');
wp_cache_set('key', 'second');
$value2 = wp_cache_get('key');
What are the values of $value1 and $value2?
Wordpress
wp_cache_set('key', 'first');
$value1 = wp_cache_get('key');
wp_cache_set('key', 'second');
$value2 = wp_cache_get('key');
A$value1 = 'first', $value2 = 'second'
B$value1 = null, $value2 = 'second'
C$value1 = 'second', $value2 = 'second'
D$value1 = 'first', $value2 = 'first'
Attempts:
2 left
💡 Hint

Think about what happens when you set and get cache values in order.