jdriscoll/django-imagekit — pull request #81 by mkai (2011-12-08 16:36:35+00:00)
Title: Only generate a new image on demand if ``pre_cache`` is disabled

Hi,

I have a remote storage backend that uses SFTP for file operations (very slow) and HTTP for getting the file itself (very fast). Due to the slowness of the backend, I have set ``pre_cache=True`` so that after an image has been processed (thumbnails created, etc.), I can avoid calling SFTP operations as much as possible for performance reasons. Even calling ``exists()`` has a noticeable impact on performance.

I've noticed that ``ImageSpecFile.generate()`` is called every time the model's ``url()`` or ``_get_file()`` is called. Because ``generate()`` does an ``exist()`` call on the storage backend, I have disabled generating the image if ``pre_cache`` is True.

I'm not sure if my fix is the right one for this problem, but it seems to work for me.