Imagecache
Imagecache stats
- Downloads
- 5.9M
- Stars
- 633
- Open Issues
- 48
- Forks
- 96
Caching extension for the Intervention Image Class
Intervention Image Cache Summary
Intervention Image Cache is an extension for the popular Intervention Image Class package, designed to add powerful image caching capabilities. Utilizing the Illuminate/Cache package, it integrates seamlessly with the Laravel framework, allowing developers to efficiently handle image manipulations by caching results. This reduces the need for repetitive processing and improves performance by storing image operations in various cache stores such as Filesystem, Database, Memcached, or Redis.
Main Features
- Simple Integration: Easily integrates with Laravel and other systems using PSR-4 autoloading.
- Flexible Caching: Compatible with multiple caching backends including Filesystem, Database, Memcached, and Redis.
- Efficient Performance: Checks if an image operation sequence is already cached, skipping resource-intensive processing.
- Dynamic Usage: Allows dynamic image manipulation while leveraging caching to avoid redundant processing.
Installation and Configuration
Install the package using Composer:
$ composer require intervention/imagecache
For Laravel integration, update config/app.php:
'providers' => [ ... 'Intervention\Image\ImageServiceProvider'], 'aliases' => [ ... 'Image' => 'Intervention\Image\Facades\Image'],
Usage
Invoke the Image::cache method to perform and cache image operations:
$img = Image::cache(function($image) { return $image->make('public/foo.jpg')->resize(300, 200)->greyscale();}, 10, true); // 10 minutes cache, return as object
Server Configuration
For Nginx servers using static resource caching, exclude the image cache directory to prevent caching issues:
location ~* ^\/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ { expires max; access_log off; add_header Cache-Control "public";}
Intervention Image Cache enhances image handling in applications by reducing load times and server demand through effective caching strategies, making it an essential tool for developers working with image-heavy Laravel applications.