I am trying to display random products on the homepage. but my page is getting cached and on refresh, same products are displayed. I used AJAX post request also but did not work. Can anybody say how can I avoid my page getting cached?

Read many articles, tried every possible way, but did not work. Here is my ajax code

    ], function($){
        url: "/homepage/ajax/loadcategory",
        type: "POST",
        data: "",
        success: function (res) {
            if(res.indexOf("find products matching the selection") > -1){
             alert("Hello world.......");
         alert("Hello world");
            var result = jQuery('.product-item-info', res).html();
            jQuery(".randomProd .product-item .product-item-info").html(result);

  • 1
    Can you add your Ajax code? – Toan Tam Aug 23 '19 at 11:19
  • @ToanTam Edited my question – Nafisa Aug 23 '19 at 12:04
  • try this one before adding $('.randomProd .product-item .product-item-info').empty(); – Amrit Pal Singh Aug 23 '19 at 12:07
  • @AmritPalSingh Sorry,did not work – Nafisa Aug 23 '19 at 12:23
  • Load your products by creating a block and in the xml, make that block cachable false – MGento Aug 23 '19 at 18:15

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.