Prevent backend rendering
This feature is experimental. It might not work in all use cases. Test thoroughly before using this feature in production.
Advantages and disadvantages
Rendering search results on the frontend leads to a better user experience. If the server doesn’t have to render search results pages before sending a response to users, it can respond quicker and it needs less resources. This reduces loading times and a better user experience.
To benefit from a better user experience, while still letting crawlers indexing your site, you can combine both approaches: for most users, you render the search results directly in the browser, while for crawlers, you generate the search results pages on the backend.
Leave backend rendering turned on for crawlers
You can help crawlers index your site by turning off backend rendering only for (human) users, while leaving it on for crawlers.
You can identify crawlers by their
User-Agent HTTP header.
Most crawlers have unique identifiers, distinct from regular browsers that users would use.
When you configure the Algolia extension for Magento, you can enter a list of user agents for which you want backend rendering to be turned on. By default, backend rendering is turned on for Google’s and Bing’s crawlers.
For more information, see these resources:
- List of user agents used by crawlers
- Google Search Console for checking the number of pages indexed by Google
- Bing Webmaster Tools for checking the number of pages indexed by Bing
Prevent backend rendering for most users
To prevent backend rendering, follow these steps:
- In your Magento 2 admin section, go to Stores > Configuration > Algolia Search > Advanced.
- Set Prevent backend rendering? to Yes.
- Optional: enter a list of user agents for which results should still be rendered by the backend. By default, the list contains “Googlebot” and “Bingbot”.
How preventing backend rendering works
When you enable the Prevent backend rendering setting in the Algolia extension,
the extension uses a layout XML file,
which removes these blocks from the
and these blocks from the template: