Problem/Motivation
QuickTabsController::ajaxContent() uses AjaxResponse, which does not implement CacheableResponseInterface. Cache metadata (tags, contexts) from the
rendered tab content is not bubbled onto the response. Dynamic Page Cache cannot cache the response. Core's ViewAjaxController uses CacheableAjaxResponse and bubbles
cache metadata for the same pattern (see core/modules/views/src/Controller/ViewAjaxController.php lines 148, 222–227).
Proposed resolution
Replace AjaxResponse with CacheableAjaxResponse and bubble cache metadata from the rendered content onto the response, matching what core's Views AJAX controller
does:
$response = new CacheableAjaxResponse(); $response->addCommand(new HtmlCommand($element_id, $render)); $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($render)); $response->addCacheableDependency($qt);
Issue fork quicktabs-3606675
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
loze commentedComment #4
loze commentedComment #5
joelpittetOh I didn’t expect it wouldn’t bubble it! Thanks loze!
Comment #6
loze commentedAdded missing
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($render))to bubble rendered content cache metadata to the response.Comment #8
joelpittetAdded a quick test to make sure we’re making a diff (red/green) for caching, chose a functional so we don’t test interfaces exist.
All working great, thanks again @loze!
Comment #9
joelpittet