Search code examples
pythondjangodjango-staticfiles

Static files such as videos and images take time to load in production


The video and images loaded faster when I opened the website in the local server. After hosting it, the video in the homepage takes time to load and the images retrieved from the database also take time to load. I have used AWS light sail to host the website on the internet. Please let me know what I can do to load the video and images faster when the user opens the website.

I have followed the steps to load the static files in django, but the load time is very slow.


Solution

  • Here are some tips & tricks to solve this problem.

    • You can use Aws S3 buckets to store static assets. You can also create CDNs (content delivery network) to load the css adn js faster.

    • When there's a big size of all static files it slows down the website's loading time so to solve this problem you can use django-compressor .

    • You can use django's easy-thumbnails to create the thumbnails of the image as per you requirements

    • You can check your website's page speed and some helpful tips at google's pagespeed insights