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 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)
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue