- Issue created by @a.dmitriiev
The change introduced in this issue
https://www.drupal.org/project/rest_menu_items/issues/3039979
✨
Menu Items Extras fields also returned by the API
Fixed
in comments #24 and #25 made the response of the resource uncacheable by browser. If you check the headers of the response you will see "Cache-Control: must-revalidate, no-cache, private". This is expected because of ModifiedResourceResponse
, see class web/core/modules/rest/src/ModifiedResourceResponse.php
:
/**
* A response that does not contain cacheability metadata.
*
* Used when resources are modified by a request: responses to unsafe requests
* (POST/PATCH/DELETE) can never be cached.
*
* @see \Drupal\rest\ResourceResponse
*/
class ModifiedResourceResponse extends Response implements ResourceResponseInterface {
For this reason when calling the endpoint next time, browser tries to load the menu again. Also it is not possible to use CDN with such response headers.
Install the module.
Enable rest resource.
Try to load the main menu like this: /api/menu_items/main .
Observe response headers, see that response is uncacheable.
Find the cause of cacheable metadata leaks that were identified in the issue
https://www.drupal.org/project/rest_menu_items/issues/3039979
✨
Menu Items Extras fields also returned by the API
Fixed
and add relevant metadata instead of using ModifiedResourceResponse
.
Find cacheable metadata leaks, add relevant information to the response and use ResourceResponse.
None.
None.
None.
Active
3.0
Code