i'm using image_filter resize in nginx to resize a bunch of images that are in Amazon S3. I want to be able to save the resized image so that for the 2nd and subsequent request for the image it doesn't need to get resized. I have worked out how to cache the original image in Nginx so at least the image isn't continuously retrieved from S3 but i can't work out how to cache the resized image on the nginx server. Is this possible?
here's the relevant part of my nginx config (all this server does is resize images):
location / {
try_files $uri @resizer; # directive to tell it to first look locally, then look @resizer
root /var/www/nginx-default/images/;
image_filter resize 400 300;
image_filter_buffer 2048M;
image_filter_jpeg_quality 75;
image_filter_transparency off;
error_page 415 = /empty;
}
location @resizer {
proxy_pass http://my-s3-bucket;
proxy_store on;
proxy_temp_path /var/www/nginx-default/cache$uri;
proxy_store_access user:rw group:rw all:r;
image_filter resize 400 300;
image_filter_buffer 2048M;
image_filter_jpeg_quality 75;
image_filter_transparency off;
root /var/www/nginx-default/images/;
error_page 415 = /empty;
}
location = /empty {
empty_gif;
}
Anyone any ideas...?