imageproxy icon indicating copy to clipboard operation
imageproxy copied to clipboard

Add support for X-Accel responses

Open predakanga opened this issue 8 years ago • 1 comments

Currently evaluating imageproxy for a deployment, and it seems perfect bar one minor feature.

Would it be possible to add support for X-Accel headers, to delegate the actual image serving to the downstream web server?

The way I envision this working would be a command line option such as "--x-accel=/prefix" which would cause imageproxy to generate it's headers normally, but instead of outputting the image, simply saving it to cache and adding a header X-Accel-Redirect: /prefix/path/inside/cache.

It would then be up to the administrator to map /prefix in their web server to serve images from the cache.

predakanga avatar Dec 17 '16 04:12 predakanga

one problem with this is that the httpcache package caches the entire HTTP response (headers and all), not just the image. So you couldn't just point to the existing cache file on disk, you'd have to write a new file to disk that contains only the image bytes. And by the time you're doing that, is it really any faster than returning the bytes in the response? (Or am I misunderstanding something here?)

Note also that if the upstream image has proper caching headers (etag, last-modified, cache-control, etc), then many requests don't require resending the bytes anyway.. imageproxy will just return a 304 Not Modified

willnorris avatar Jun 20 '17 15:06 willnorris