2

I use Django's cached template loader to speed up my site:

TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        ....
    )),
)

Is there a way to exclude specific templates from being cached? I have a template that I change a fair amount and I'd like to avoid having to restart my project every time I make a change to the template. Or, maybe a way to clear all cached templates without restarting the project?

I did see this Resetting cache for Django cached template loader. Maybe that can be used to exclude a template but, if so, I'm not seeing how to use it.

Edit: Someone asked if this answered my question Fighting client-side caching in Django. No, because my question has nothing to do with client-side caching.

user984003
  • 28,050
  • 64
  • 189
  • 285
  • Does this answer your question? [Fighting client-side caching in Django](https://stackoverflow.com/questions/2095520/fighting-client-side-caching-in-django) – Ivan Starostin Feb 14 '20 at 15:37
  • 1
    No. My question has nothing to do with client-side caching. – user984003 Feb 14 '20 at 19:35
  • Have you found an answer to this? I'm facing the same problem, and even after diving into Django's source code I can't find a way to get my hands on a django.template.loaders.cached.Loader to call .reset() on it, although that loader seems to be the default loader loaded – Gabriel Francischini Feb 13 '22 at 07:46
  • Nevermind, this solved a different version of your problem: https://stackoverflow.com/a/57827629/6141224 – Gabriel Francischini Feb 13 '22 at 07:50

0 Answers0