I am currently working on a REST API. I wanted to check if the HTTP cache works, but unfortunately I don't work at all. No matter what I do, it always returns HTTP code 200, while it should return 304 from what I know.
Here is my PHP code:
public function getList() { $this->addHeaders(array( 'Cache-Control' => 'public, must-revalidate, max-age=120', 'eTag' => 'xyz123', )); $array = array( 'foo' => 'bar', 'nested' => array( 'lorem' => 'ipsum', 'dolor' => 'sit amet' ) ); $this->addHeader('Content-Length', strlen(json_encode($array, true))); return new JsonModel($array); }
response / request

The ETag does not change, so requests, with the exception of the first, must be sent from the cache. I'm wrong?
I followed these two articles:
I also checked with a weak validator - Last-Modified, but I have the same problem. The browser sends the correct header to the Request , but I still get 200 in response
source share