Parecia que o json não estava sendo armazenado em cache pelo wp-super-cache, mas decidimos adotar uma abordagem diferente. Ao usar a API transitiva , conseguimos fazer um cache falso em todos os json e reduzir drasticamente a sobrecarga do banco de dados. Então, no lado do ajax, estamos armazenando em cache o html que é criado a partir desse json semi-armazenado em cache. As coisas estão super velozes! Aqui está uma versão reduzida do código e conceito.
$transient_key = 'my-transient-key';
$data = get_transient( $transient_key );
if ( $data == '' ) {
$args = array(
'post_type' => 'brand',
'posts_per_page' => 50
);
$postsArray = array();
// The Query
query_posts( $args );
// The Loop
while ( have_posts() ) : the_post();
$brand_id = get_the_ID();
$slug = basename(get_permalink());
$title = get_the_title();
$description = get_the_content();
$posts = array(
'brand_id' => $brand_id,
'machine_name' => $slug,
'postTitle' => $title,
'description' => $description,
);
array_push($postsArray,$posts);
endwhile;
$data = json_encode($postsArray);
set_transient( $transient_key, $data, 60 * 60 * 24 ); // one day
} // now all the brand information is cached as one table call.
echo $data;