clokep / django-render-block

Render the content of a specific block tag from a Django template.
ISC License
240 stars 23 forks source link

Django nodes cache #40

Open iurisilvio opened 2 years ago

iurisilvio commented 2 years ago

It is really slow to parse templates everytime you call render_block and it is a static information, so you can cache it in memory.

I did some benchmarking here and this node cache improved performance ~20%.

Most part of the work was done by @walison17, I just wrote a test and did the benckmark.

clokep commented 2 years ago

Looks like this needs black run against it for formatting! 👍

iurisilvio commented 2 years ago

Yes, I ran black and fixed the formatting.

iurisilvio commented 1 year ago

I added a commit here to support anonymous templates. It is a case where template.name is None, so it was clashing cache keys.