Support

Account

Home Forums General Issues Caching multiple ACF values until they change Reply To: Caching multiple ACF values until they change

  • get_field() is no less optimized that get_post_meta(), in fact, get_field() is just a wrapper for get_post_meta() that formats the value in a specific way before returning the value. If you use get_post_meta() then you need to do all that formatting work yourself anyway.

    There can be times when you may be doing extra DB calls when getting one field at a time, but these conditions are rare. You might see some improvement by calling get_post_meta() without specifying a meta key before getting any fields. For example $meta = get_post_meta($post_id);. What this does is forces WP to get all of the meta values for a post and to store those values into the cache so that no db calls will be needed to get values later on. After this you can go ahead and use the ACF functions as normal and be sure that no extra db calls are made.

    The best bet you have for improved performance is to install one of the caching plugins that are available for WP. This stores a static version of the page so that it is only updated when a change is made, dependent on the settings you use for them.