Hello. What is the best way to organize photo storage?

How best to save images from users (avatar, cover page, posts on the wall, etc.). How many sizes? For example, a miniature 60x60, the main profile photo 200x200, an enlarged version - 1000x1000. So? And how then to optimize it? In the script, if there are three photos stored immediately, will it take too long to occur?

  • After all, you can cache. I know for sure that in Django when using sorl, the pictures are cached when the page is first rendered. - YozhEzhi
  • It is not clear what speed in question. At the beginning of the question, it seems to be about showing the pages of the site, and then the author smoothly slides to download photos. I think he needs to decide what he is asking about - Ipatiev
  • @ Ipatiev Resize a large photo into a thumbnail increases page load time. Therefore, I understand what is needed when saving a photo, save it in several sizes. So I ask how best to organize the preservation of thumbnails. It is also desirable that it does not take much time. - Dmitriy
  • Well, you need to ask about it, and not spread out on tree - Ipatiev
  • @ Ipatiev I apologize if I could not immediately formulate normally - Dmitry

2 answers 2

If this is a directory, then you can organize lazy load. Jquery plugin

The second option is http caching. More details on it (I also recommend reading ).

Well, make thumbs . And you choose the permits for your project.

  • Thank you very much! - Dmitry
  • Please, happy to help :) - Kostiantyn Okhotnyk

Create thumbnails by crown or through queues. Then the user will not wait. You can also create a thumbnail when you first access it. For example, if you configure nginx so that the presence of statics is first checked on .jpg, and if not, the request is sent to a script that generates a thumbnail and returns it to output. The next call will be given immediately static.

  • one
    Thank you very much. I did not work with crowns or queues ... We'll have to google. - Dmitriy