Unable to Control Caching for a Resource Extending EntityResourceBase

Created on 23 September 2021, about 3 years ago
Updated 4 January 2024, 12 months ago

I'm attempting to create a resource that should rarely be cached (making it uncacheable would probably be reasonable.) My resource extends EntityResourceBase but I'm finding that the resource is cached pretty aggressively.

As a starting point, I'm trying to make the resource uncacheable, but am having no luck.

I've tried the no_cache option in routing.yml

options:
    no_cache: TRUE

Within the process method on the class I've tried a number of things to make things uncacheable - making the response private, setting a max age of 0, even resorting the the kill switch :) Nothing seems to have an impact.

I'm taking this approach to building the response:

$data = $this->createIndividualDataFromEntity($entity);
$response = $this->createJsonapiResponse($data, $request);

Are there any examples out there that show how to override this caching? EntityQueryResourceBase seems to give more control over cacheability, but an entity query isn't really appropriate for this endpoint.

πŸ’¬ Support request
Status

Closed: works as designed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brianperry

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