Image and CSS pre loading in Django

Viewed 38

I am developping a website with Django, hosted on Heroku, and still fairly new to it.

I published my application, and notice a problem when navigating on the hosted website :

Whenever you load a new page, it looks like images and css are reloading completely. For a short time (less than 1 second), It creates some king of glith on my menu bar because buttons are moving (because the image is missing) and changing color (because css is missing).

What would be a proper way to handle this ? Is it possible to store those image and css in somme kind of cookie on the user browser ?

Also, when i run the website on my localhost, i don't experiment the problem.

Thanks for your help !!

2 Answers

This not a issue per se, but due to the fact that your css image are not probably optimised, that plus Heroku is not your local server so the response time is slower, this is why you notice the static files being loaded.

However this is not a bug, depending on how big your statics are it will be more or less noticeable.

Your images and css will be cache on the client browser (not the cookie) so the website will run faster after several visits to your website.

Finally found the reason for cookie to be desactivated, i was still in DEBUG_MODE !

Related