django: guidelines for speeding up template rendering performance

前端 未结 4 1771
太阳男子
太阳男子 2020-12-24 08:59

How would I go about speeding up Django template rendering? My template takes about 1-2 seconds or so to render, after the view function fully computes whatever it needs to.

4条回答
  •  孤独总比滥情好
    2020-12-24 09:48

    Use ManifestStaticFilesStorage to serve your static files. The performance boost I've witnessed relative to using CachedStaticFilesStorage with the default LocMemCache is immense. The difference being no hashes ever need to be calculated at runtime.

    I don't quite know why the difference is as huge as it is - while it's true that CachedStaticFilesStorage would initially need to calculate hashes and fill the cache, once the cache is filled I wouldn't expect a significant performance penalty relative to the manifest method. But it is massive, and the documentation also recommends using ManifestStaticFilesStorage for performance.

提交回复
热议问题