I need to display the below sections in Wordpress website using another API:

  1. Products search
  2. Products listing with pagination
  3. Popular products
  4. Stores section
  5. Categories and sub-categories section
  6. Similar Products

We have around 5 pages related to this section.

I am planning to implement this with ajax, wp_remote_get(), and TLC transients.

a) We have to display a large amount of data on the website. So it will add transients (a large amount of data) to the options table. Will this affect site performance?

b) Should we use any transient cleaners to remove the expired TLC transients?

c) Changing the limit in the API URL will not reflect in the transient data even after the expired time. Will this take time? Is this a known issue?

function test_tlc_transient() {
    $t = tlc_transient( 'popular-products' )
        ->expires_in( 300 )
        ->updates_with( 'sample_fetch_and_append', array( 'http://siteurl/restapi/frontend/GetMostProductViewed?start=0&limit=12' ) )
    var_dump( $t );
    if ( !$t )
        echo "The request is false, because it isn't yet in the cache. It'll be there in about 10 seconds. Keep refreshing!";
function sample_fetch_and_append( $url ) { 
    $f  = wp_remote_retrieve_body( wp_remote_get( $url, array( 'timeout' => 30 ) ) ); 
    return $f;

d) Do we have any better alternatives to implement this?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.