I am trying to cache images, with not luck. The response is only the image, and it works. But not the cache.
This is the only Controller (the response is the image itself and the .ico file):
PHP Code:
public function getImage($filename = null)
{
$basefolder = 'test/';
$filename = $basefolder.$filename;
$this->response->setHeader('Content-Type',mime_content_type($filename));
$cacheOptions = [
'max-age' => DAY
];
$this->response->setCache($cacheOptions);
readfile($filename);
}
And this is the response header:
Code:
HTTP/1.1 200 OK
Date: Mon, 25 May 2020 19:52:44 GMT
Server: Apache/2.4.38
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: max-age=86400
Pragma: no-cache
Debugbar-Time: 1590436364
Debugbar-Link: https://blog.casa.spiti/?debugbar_time=1590436364
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg
What means the expiring date of 1981 and how do I change it?
I also noticed, that the image is described as docuement in the Network analysis tab. How can I change that? Is it because I am using readfile? Is there a better option for that? Same for videos, btw.