I am using Drupal 8 so there is very little documentation or benchmarks, but I believe a route I have set up for ajax responses is not as performant as it could be. This is the route:
next_node.ajax:
path: '/node/{node}'
defaults:
_controller: '\Drupal\next_node\Controller\DefaultController::view'
requirements:
_permission: 'access content'
_format: 'json'
_access: 'TRUE'
And this is the controller:
class DefaultController extends EntityViewController {
/**
* {@inheritdoc}
*/
public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
$build = parent::view($node);
return new AjaxResponse(\Drupal::service('renderer')->renderPlain($build));
}
}
I request the content through this function:
jQuery.get( "/node/2?_format=json", function( data ) { /* Do stuff */ });
Is it normal that it takes about a second on average to get a response? Where to optimize the code?