I personally use nginx as frontend, apache as after sales. I want cache pictures, but automatically nginx is caching file by extentions. Apache takes pictures from db and send it without extentions. Can nginx cache files by mime type and just how?

You'll need something similar to this.

if ($upstream_http_content_type ~* "image/") {
    DEFINE_YOUR_CACHE_SETTINGS
}