0

i'm working with Intervention Image and his extension for the cache Intervention Image Cache It work pretty well.

What i'm trying to be able is to cache the image on the browser with the headers and Intervention.

Wich is the best way to achieve that?

let's say I have a route, it hooked an a method to my controller that handle the response for show the image like so:

public function showImage($name_image)
    {
        // how can set the headers for get image cache on browser?
        $img = Image::cache(function($image) use ($name_image) {
               return $image->make('myFolderPathImage'."/".$name_image);
            });

        return Response::make($img, 200, array('Content-Type' => 'image/jpeg'));
    }
Fabrizio Fenoglio
  • 5,767
  • 14
  • 38
  • 75
  • you can refer this link [caching dynamic images with Laravel Intervention library not working](https://stackoverflow.com/questions/31009027/caching-dynamic-images-with-laravel-intervention-library-not-working) – harri Mar 28 '18 at 08:49
  • you can refer this link [caching dynamic images with Laravel Intervention library not working](https://stackoverflow.com/questions/31009027/caching-dynamic-images-with-laravel-intervention-library-not-working) – harri Mar 28 '18 at 08:51
  • you can refer this link [caching dynamic images with Laravel Intervention library not working](https://stackoverflow.com/questions/31009027/caching-dynamic-images-with-laravel-intervention-library-not-working) – harri Mar 28 '18 at 08:53

1 Answers1

0

your above code works very well for me though here is some code for a laravel 4.2 route it may help.

Route::get('/image/{image}', function($id) {
 if (!File::exists('public/img/g_icons/'.$id)) return Response::view('errors.missing', array(), 404);
 $img = Image::cache(function($image) use ($id) { $image->make('public/img/'.$id); },10080);
 return Response::make($img, 200, array('Content-Type' => 'image/png'));
});
Jamie
  • 23
  • 4