Ajout cache expires
This commit is contained in:
parent
a08c93f650
commit
5d5a9bd4cb
|
@ -10,8 +10,6 @@ use Intervention\Image\Exception\NotSupportedException;
|
||||||
use Laravel\Lumen\Routing\Controller as BaseController;
|
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||||
use Meoran\Images\Model\Image;
|
use Meoran\Images\Model\Image;
|
||||||
use Meoran\Images\Templates\Custom;
|
use Meoran\Images\Templates\Custom;
|
||||||
use ReflectionFunction;
|
|
||||||
use ReflectionMethod;
|
|
||||||
|
|
||||||
class ImagesController extends BaseController
|
class ImagesController extends BaseController
|
||||||
{
|
{
|
||||||
|
@ -44,11 +42,12 @@ class ImagesController extends BaseController
|
||||||
return response()->json($image);
|
return response()->json($image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id) {
|
public function delete($id)
|
||||||
|
{
|
||||||
$image = Image::findOrFail($id);
|
$image = Image::findOrFail($id);
|
||||||
$image->delete();
|
$image->delete();
|
||||||
|
|
||||||
return response()->json("Delete ".$id." succesfully");
|
return response()->json("Delete " . $id . " succesfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getOriginal($filename)
|
private function getOriginal($filename)
|
||||||
|
@ -141,11 +140,13 @@ class ImagesController extends BaseController
|
||||||
{
|
{
|
||||||
// define mime type
|
// define mime type
|
||||||
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
|
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
|
||||||
|
$timeInSecondsToExpire = config('image.lifetime') * 60;
|
||||||
|
|
||||||
// return http response
|
// return http response
|
||||||
return response($content, 200, array(
|
return response($content, 200, array(
|
||||||
'Content-Type' => $mime,
|
'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)
|
'Etag' => md5($content)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue