How to decrease throughput AJAX requests in Magento 2 to improve performance
Since throughput requests may cause significant server load in Magento 2, you may experience dramatic performance decrease. In the following post, we guide you through fixing the issue, optimizing the productivity of your e-commerce website. More useful tips are available here: Magento 2 Cookbook.
Table of contents
Issue
High throughput requests, such as critical AJAX requests, lead to Magento 2 performance decrease. The problem is usually related to private content. As for the solution, there are two options.
Solution
To increase Magento 2 performance affected by throughput AJAX requests, you can ensure lighter requests. It is possible to cache requests or rely on customer private content.
At the same time, you may try to reduce the number of requests.
Lighter requests
It is recommended to rely on lighter requests if there are third-party AJAX requests triggered on each page. To reduce the server load, you should cache them or move to customer private content.
If custom AJAX requests are called via the GET HTTP methods, Fastly can cache them. If you cannot cache them, refactor the requests according to private-content functionality. Follow this link for further information:
Reduced request quantity
Below, we provide several more performance improvements related to the throughput requests. The first tip is related to the persistent shopping cart. You can turn it off to make your store a little bit faster. The persistent shopping cart may negatively affect Magento 2 performance by increasing the number of customer/section/load requests. And you are already familiar with the consequences. You can disable the feature under Stores-> Settings-> Configuration-> Customers-> Persistent Shopping Cart.
As for the second tip, it is about reloading. You can reload or invalidate content in sections.xml to increase the performance of your Magento 2 website. The detailed guide is available here:
You can also check other POST AJAX requests. You need Chrome and the Google Chrome developer tool:
- Open the browser;
- Open the tool;
- Open the Network tab;
- Open the XHR tab;
- Find a list of all AJAX requests from the selected page.
- Click on each request and view the Request Method field. It should display GET requests.
Also, note that the GTM (Google Tag Manager) functionality is a specific AJAX request. You can rely on the private functionality to reduce the total number of requests to the server and increase Magento 2 performance.
If a Magento banner is enabled but not used, it may also decrease the performance of your e-commerce store. Disable the Magento Banner output to make your website faster. You can find more information here: