Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching behaviour with default settings #47

Open
arneb opened this issue Feb 18, 2014 · 5 comments
Open

Caching behaviour with default settings #47

arneb opened this issue Feb 18, 2014 · 5 comments

Comments

@arneb
Copy link

arneb commented Feb 18, 2014

Since the introduction of the CACHES setting Django by default uses the LocMemCache backend. Using multiple Django processes on the server, each process maintains it's own cache (as documented here: https://docs.djangoproject.com/en/1.6/topics/cache/#local-memory-caching).

I think this yields to outdated templates in the cache of all processes, except the one, that was used to save a change through the Django Admin.

Setting DBTEMPLATES_CACHE_BACKEND to None does not change the behaviour.

I think this behaviour needs to be documented, because I have to actively disable the LocMemCache setting to fix the problem with stale db-templates.

If I don't use caching at all in a project, I would normally not think about altering the Django default setting.

Environment: Django 1.6.2, Python 2.7.5, dbtemplates 1.3

Possibly related to #43

Edit: Using a DummyCache as the default cache fixed the problem with stale db-templates completely.

@jezdez
Copy link
Member

jezdez commented Feb 18, 2014

Have you tried setting a LOCATION of the locmem backends as described in the Django settings?

@arneb
Copy link
Author

arneb commented Feb 18, 2014

No, because the point I wanted to make is: "If my project does not use Django's Cache Framework at all, I will never think about changing the CACHES setting and that will break dbtemplates".

If I make any use of Django caching in my project, I will definately use a cache backend thats works for my setup and then dbtemplates will of course work correctly.

The documentation says (https://github.com/jezdez/django-dbtemplates/blob/develop/docs/advanced.txt#L7):

To enable one of them you need to specify a setting called DBTEMPLATES_CACHE_BACKEND ...

And:

Starting in version 1.0 dbtemplates allows you also to set the new dict-based CACHES setting,
which was introduced in Django 1.3.
All you have to do is to provide a new entry in the CACHES dict named 'dbtemplates', e.g.:

What's missing is a clear indication that, If I do nothing, it will use CACHES['default'] and I have to make sure, that it's configured to work for my envirnoment.

After reading the documentation I thought that dbtemplates would only use the cache, if I activated it somehow. But it does it silently by default.
Then Django's default (LocMenCache) combined with my Process-based Django Workers lead to the strange behaviour of seeing outdated templates from some workers.

I opened the ticket because I think it might save others some time if this would be mentioned in the documentation.

@jezdez
Copy link
Member

jezdez commented Feb 19, 2014

Ah, okay, thanks for the clarification, I'm sorry you had to find out that implicit behavior the hard way. This needs to be clarified indeed.

@mpasternak
Copy link
Contributor

@arneb thank you for this problem report, would you mind submitting a pull request against the current docs?

@guettli
Copy link

guettli commented Sep 30, 2022

Maybe this will be solved via PR #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants