Search code examples
javascriptjquery-ias

Infinite Ajax Scroll v3 adds random numeric query params to page URLs


I've a got a strange problem with Jquery-IAS (http://infiniteajaxscroll.com/) v3.0.0-beta6. It adds random numeric query params to page URLs. For example, it try to load /?page=2&1612427293001 instead of /?page=2 and gets 404 error. Can't find anything about that in documentation. Please help!

Here are my paginator links HTML-code:

<ul class="pagination pagination-sm justify-content-center pagination-ias" id="pagination">
 <li id="page-item-1" class="page-item active">
   <a class="page-link"  href="https://www.y8games.center">1</a>
 </li>
 <li id="page-item-2" class="page-item next">
  <a class="page-link"  href="https://www.y8games.center/?page=2">2</a>
 </li>
 <li id="page-item-3" class="page-item ">
  <a class="page-link"  href="https://www.y8games.center/?page=3">3</a>
 </li>
 <li id="page-item-4" class="page-item ">
  <a class="page-link"  href="https://www.y8games.center/?page=4">4</a>
 </li>
</ul>

Here is my JS code:

let ias = new InfiniteAjaxScroll('#catalog', {
        item: '.game-item:not(.game-item-new)',
        next: '.next a',
        pagination: '#pagination',
        spinner: {
          element: '.ias-spinner',
          delay: 500,
        },
      });

Thanks you for help!


Solution

  • The random number is part of a cache busting mechanism, as described here: https://developer.mozilla.org/nl/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache

    In a later version (current master branch) a way to disable this was added, by setting the noload flag on the load event to true, see https://docs.infiniteajaxscroll.com/reference/events#load

    TL;DR:

    ias.on('load', function(event) {
      event.nocache = true; // prevent IAS from adding a timestamp query param to the url
    });