I created a simple rest endpoint to test caching and I see the response updating. What is stopping it from being cached?
Here’s the rest endpoint code:
<?php namespace Drupalnm_base_apiPluginrestresource; use DrupalrestResourceResponse; use DrupalrestPluginResourceBase; /** * This is just an example. * * @RestResource( * id = "test", * label = @Translation("Test"), * uri_paths = { * "canonical" = "/api/v1/test" * } * ) */ class Test extends ResourceBase { /** * {@inheritdoc} */ public function get() { $response = new ResourceResponse( [ 'title' => 'test', 'time' => time(), ] ); return $response; } }
And here’s what I see in response:
$curl 'http://base.test:8020/api/v1/test' {"title":"test","time":1651152255}$ curl 'http://base.test:8020/api/v1/test' {"title":"test","time":1651152256}$ curl 'http://base.test:8020/api/v1/test' {"title":"test","time":1651152257}$ curl 'http://base.test:8020/api/v1/test'