Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Wade Kallhoff 4 posts 71 karma points
    Aug 13, 2014 @ 21:56
    Wade Kallhoff
    0

    Conditional request for remotely hosted images

    In a previous discussion we concluded that ImageGen is making a full request out to each remotely hosted image, retrieving the image, and checking if it has changed. If it has changed, resize, cache, and return image. If it hasn't change, return the cached image on disk.

    The problem here is that for each request, it is still going out and fetching the remotely hosted image in whole.

    Is there any way for ImageGen to utilize a conditional request out to the remotely hosted image so that it doesn't pull down the full image during each request? 

    I'm assuming it would look like this: Image is requested, check disk for cached image. Find cached image and check disk write timestamp. Make a conditional request out to the remote server, passing along the timestamp of the cached image as the check. The remote server will return a 304 not modified, letting ImageGen know that the image has not been modified since the provided timestamp and that it can continue with serving up the image cached on disk. 

    Is that something that can be implemented? If not, what other server side caching features exist for remotely hosted images?

    The real brunt of the problem is that our site needs to support Retina which means that the content editor needs to upload images at 2x the normal size. This is resulting in larger image file sizes which results in a noticable lag when loading from ImageGen. 

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Aug 18, 2014 @ 13:33
    Douglas Robar
    0

    Hi, Wade,

    Sorry for the slow response... I've just gotten back to the UK from a holiday in the USA.

    You are correct that ImageGen makes an http request for the remote source image. Typically (though not always and this is where it can be a bother) the bandwidth between the remote image server and the web server with ImageGen is very large (often on the same internal network or between large data centers) and so there is little penalty for sending even large images to ImageGen from a remote site.

    That's a nice idea for limiting the download of the original image to just a 304 response from the remote source if possible, rather than comparing the image in ImageGen itself. I'll add that to the todo list as an enhancement.

    The key to performance here is to limit the number of requests to ImageGen by using client-side caching with ImageGen (using the 'class' features of ImageGen Professional). That way, only initial visits would make requests to the remote source that way. Beyond that, proxy caching techniques might be helpful.

    I'm surprised if you're seeing a noticable difference between requesting an image as <img src="http://example.com/photo.jpg" /> and <img src="/imagegen.ashx?class=thumbnail&image=http://example.com/photo.jpg" /> If you are, there may be an overarching problem that is causing ImageGen to be slow (did we already talk about not having shared 'cached' folders between servers, for instance?)

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft