Cache issue with WP_Query and custom field filtering

Found a fix. Apparently CMB doesn’t use integers while saving values to database from custom checkboxes, but rather adds an on string when a checkbox is checked.

Also when a previously checked checkbox is unchecked, the corresponding row isn’t removed from wp_postmeta table, but remains there with an empty value.

So this will return all posts that at some point have had the checkbox active:

'meta_key' => '_cmb_work_front_large',
'meta_value_num' => 1

And this will show only the active ones:

'meta_key' => '_cmb_work_front_large',
'meta_value' => 'on'

error code: 523