[Django]-Django template includes slow?

28👍

Template rendering time is normally much smaller than database time in especial, so typically you don’t need to worry about it early on; there are other regions where performance can be increased more effectively.

For deployment, you can usually increase the performance of template inclusions by using the cached loader (you may need to scroll down a bit). Then it only loads templates once and thereafter it can use the compiled template instead of needing to load it from disk.

To address the question of template rendering overhead, once you’ve got it cached, it’s quite cheap. I wouldn’t worry about it at all. Do it in such as way as to maximise the maintainability of your system.

It would probably be irresponsible of me to not mention (hopefully, remind you of) two adages of performance optimisation; they are common enough sayings that you should be able to find plenty of information on them if you are not familiar with them.

  1. Don’t optimise prematurely.
  2. Measure—don’t guess.

Leave a comment