Performance: Options API for site-wide settings
This affects page load speed by controlling how site-wide settings are loaded and cached, impacting server response time and frontend rendering.
<?php if ( ! isset( $cached_value ) ) { $cached_value = get_option('my_setting'); } $value = $cached_value; ?>
<?php $value = get_option('my_setting'); ?>| Pattern | Database Queries | Server Response Time | Frontend Impact | Verdict |
|---|---|---|---|---|
| Repeated get_option calls | Multiple per request | High | Slower LCP | [X] Bad |
| Cached get_option call | One per request | Low | Faster LCP | [OK] Good |
add_option('site_color', 'blue');
update_option('site_color', 'green');
echo get_option('site_color');update_option('header_text', 'Welcome!');
add_option('header_text', 'Hello!');
echo get_option('header_text');Pass the test and this pattern moves unknown