Try to code it. You will see that it won't work. I have tried twice.

fyi the path that is requested needs to be the path where the image is saved. You ***should not*** be redirecting to a different path. Otherwise you are creating too much work for the server.

If the resolver to the runtime config outputs '/a/b/c.jpg' it ***should*** save as '/a/b/c.jpg'. When that path is printed the second time it doesn't have to do a 301 redirect. Otherwise, if you have a page that displays 30 images it will result in 60 requests (and that is just those images).