I have folder with a lot of pictures. I want to resize this images and push them to cache so if someone wants to use them again they will be in cache. I achieve this with this nginx setup:
server {
server_name localhost;
listen 8888;
root /media;
location ~ "^\/(?<gallery_id>.+)\/(?<width>\d+)\/(?<height>\d+)\/(?<image>.+)$" {
root /media;
try_files /$gallery_id/$image =404;
image_filter resize $width $height;
image_filter_buffer 100M;
}
}
proxy_cache_path /media-cache/images-cache/ levels=1:2 keys_zone=media-cache:1m inactive=365d max_size=500m;
server {
server_name localhost;
listen 80;
location ~ "^/(?<gallery_id>.+)/(?<width>(160))/(?<height>(120))/(?<image>.+)$" {
proxy_pass http://localhost:8888;
proxy_cache media-cache;
proxy_cache_valid 200 365d;
proxy_cache_key $width-$height-$image;
}
Now when I delete a picture from gallery this picture is still in a cache.
How can I achieve that when picture is deleted from gallery, also cache is deleted for that image?