This page covers how to set the number of Ajax Requests.

By default, the JavaScript Agent limits the Ajax requests (using XHR or the Fetch API) sent for base or virtual pages. The limit is 250 requests for single-page applications (SPAs) and 50 for non-SPAs. Although base or virtual pages normally do not send large amounts of Ajax requests, in some cases, a page may send redundant Ajax requests, especially those containing error reports.

For example, a series of redundant Ajax requests containing a dead loop of errors and exceptions with no new information could overload the EUM Server. To prevent an overload of Ajax requests, you can configure the JavaScript Agent to limit the number of Ajax requests sent for base and virtual pages.

Set the Number of Ajax Requests

The code example below limits the number of Ajax request per base or virtual page to 7.

<head>
   <script type='text/javascript' charset='UTF-8'>
      window["adrum-start-time"] = new Date().getTime();
      window['adrum-config'] = {
         xhr: {
            maxPerPageView: 7
         }
      };
      ...   
   </script>
   <script src='//cdn.appdynamics.com/adrum/adrum-latest.js' type='text/javascript' charset='UTF-8'></script>
   ...
</head>
JS

Set an Unlimited Number of Ajax Requests

For use cases where all Ajax requests for a page need to be captured, you can configure the JavaScript Agent to report an unlimited number of Ajax requests per page with the configuration xhr.maxPerPageView.

To prevent an overload of Ajax requests, it is highly recommended to only use this configuration for use cases when you absolutely need to capture all Ajax requests.


The following code example configures the JavaScript Agent to report an unlimited number of Ajax requests per page:

<head>
   <script type='text/javascript' charset='UTF-8'>
      window["adrum-start-time"] = new Date().getTime();
      window['adrum-config'] = {
         xhr: {
            maxPerPageView: "UNLIMITED"
         }
      };
      ...   
   </script>
   <script src='//cdn.appdynamics.com/adrum/adrum-latest.js' type='text/javascript' charset='UTF-8'></script>
   ...
</head>
JS