If your website is using AJAX requests to load dynamic information, you may notice that the requests take a lot of time to be executed and for the information to be displayed on the website.
To make the requests faster, NitroPack provides the “Cache AJAX URLs” option.
How does the “Cache AJAX URLs” option work?
The option that NitroPack provides, as it is stated in the name, simply caches selected Ajax requests. When we cache them, we perform basic page caching. This means that we capture the output of this function and then save it in an HTML file, which we can then reuse to display the information faster.
In the example below, you can see an AJAX request loading before it was cached:
The AJAX request takes a bit more than a second to load and shows the dynamic information.
After the “Cache AJAX URLs” option is enabled and configured properly, the loading time of the AJAX request is drastically reduced:
When the AJAX request is cached, the loading time shown above is reduced from 1.09s to 18ms.
How to configure the “Cache AJAX URLs” option?
To configure the option for your website, you have to first inspect the page on which the AJAX calls are fired and fetch the URL of the AJAX call.
In case there are multiple AJAX URLs (for example, if there is an AJAX pagination and the URL looks similar to this “<URL>/wp/page/2/”), you can extract a common part of the URL and use it with wildcards instead of adding all URLs manually.
After you have the AJAX URL, you need to simply add it to the “Cache AJAX URLs” section:
Finally, save the settings, and from now on, the URLs added in the section will be cacheable.
📌 If you need any assistance or have questions, you can contact our Support team using the chat bubble on the bottom right of this page.