Performance improvement with AJAX and Forms

Created on 15 November 2017, about 7 years ago
Updated 17 March 2023, over 1 year ago

Problem summary

AJAX requests are always made using POST, which disables render caching ( https://www.drupal.org/node/956186 ).

Further (reason behind creating separate issue) - AJAX requests in form submit, form element validate, ajax at form element levels use the same URL as the page (partially covered in https://www.drupal.org/node/2504115 ).

When the AJAX request is made - first because of POST, second because of URL being the same as current page, it processes every region, block on the page including hook_ENTITY_TYPE_view, hook_form_alter (for all the forms) and anything inside as even render cache is disabled.

In such calls, we usually want only part of the form to be processed and updated and don't want anything except the form to be processed. This results into huge impact to performance, especially if there is dynamic or processed content added to node in hook_node_view or for instance there are related content blocks on the page, hook_node_view is called for each node rendered on the page (same for any other entity if used)

Proposed solution

  • Allow AJAX callbacks to use different URL than current URL.
  • For POST (or any) requests, allow setting a configuration in routes.yml which, if set true, will not process any region/block on the page and only the required form is processed.
Feature request
Status

Closed: duplicate

Version

10.1

Component
Ajax 

Last updated about 19 hours ago

Created by

🇮🇳India nikunjkotecha India, Gujarat, Rajkot

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024