I have a custom infinite scroll that is working perfectly but it\'s really slow. Here is the script that handles the ajax request:-
function ga_infinite_scroll()
@Mikepote's suggestions for ga_price increased the speed but editing the main product loop based on unique transient increased speed more. I hereby attach my code:-
if( empty(get_transient('ga_loop_products_'.md5(serialize($params))))){ //using md5 and serialize(for 32digit) to assign a unique name to the given set of params
query_posts( $params);
ob_start();
add_filter( 'woocommerce_get_price_html', 'ga_show_price' );//filter to fix price range
if ( have_posts() ) {//product loop
if ( wc_get_loop_prop( 'total' ) ) {
while ( have_posts() ) {
the_post();
wc_get_template_part( 'content', 'product' );
}
}
}
$data = ob_get_clean();
// $ga_loop = get_transient('ga_loop_products_'.md5(serialize($params)));
set_transient( 'ga_loop_products_'.md5(serialize($params)), $data, 24 * 60 ); // 1 day cache
}
else{
$data= get_transient('ga_loop_products_'.md5(serialize($params)));
}
wp_reset_query();