Ajout cache expires

This commit is contained in:
Cassandre Cantet 2018-09-04 12:27:33 +02:00
parent a08c93f650
commit 5d5a9bd4cb
1 changed files with 6 additions and 5 deletions

View File

@ -10,8 +10,6 @@ use Intervention\Image\Exception\NotSupportedException;
use Laravel\Lumen\Routing\Controller as BaseController;
use Meoran\Images\Model\Image;
use Meoran\Images\Templates\Custom;
use ReflectionFunction;
use ReflectionMethod;
class ImagesController extends BaseController
{
@ -44,7 +42,8 @@ class ImagesController extends BaseController
return response()->json($image);
}
public function delete($id) {
public function delete($id)
{
$image = Image::findOrFail($id);
$image->delete();
@ -141,11 +140,13 @@ class ImagesController extends BaseController
{
// define mime type
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
$timeInSecondsToExpire = config('image.lifetime') * 60;
// return http response
return response($content, 200, array(
'Content-Type' => $mime,
'Cache-Control' => 'max-age=' . (config('image.lifetime') * 60) . ', public',
'Cache-Control' => 'max-age=' . $timeInSecondsToExpire . ', public',
'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time() + $timeInSecondsToExpire),
'Etag' => md5($content)
));
}