243 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
140
views
Why is Django not using the specified cache backend?
As a simple test, I'm attempting to set the cache backend used by Django to something other than the default django.core.cache.backends.locmem.LocMemCache. I'm using a custom backend defined in the ...
0
votes
1
answer
43
views
Django, can I force a request to bypass the cache, even if the cache key already exists
settings.py
['django.middleware.cache.UpdateCacheMiddleware'] + MIDDLEWARE + ['django.middleware.cache.FetchFromCacheMiddleware']
middleware.py
def middleware(request):
if global_value % ...
1
vote
0
answers
53
views
object attribute is missing after manager.py is restarted when using django redis cache
Here is the sample code:
class CrossSection(LoggerMixin):
pass
class CrossSectionFactory(LoggerMixin):
cross_section_sequence = {}
def add(self, date):
cross_section = ...
1
vote
3
answers
73
views
`dir()` doesn't show the cache object attributes in Django
I can use these cache methods set(), get(), touch(), incr(), decr(), incr_version(), decr_version(), delete(), delete_many(), clear() and close() as shown below:
from django.core.cache import cache
...
0
votes
1
answer
105
views
Is it needed to use `cache.close()` after finishing using cache in Django Views?
I found cache.close() saying below in the doc. *I'm learning Django Cache:
You can close the connection to your cache with close() if implemented by the cache backend.
So, I use cache.close() after ...
2
votes
1
answer
498
views
How to get the contents of the cache properly in Django?
I set 4 cache values with LocMemCache as shown below:
from django.core.cache import cache
cache.set("first_name", "John")
cache.set("last_name", "Smith", ...
2
votes
2
answers
183
views
Does `cache.set()` use `version=1` by default instead of `version=None` in Django?
If I only set and get David with version=0, then I can get John and David in order as shown below. *I use LocMemCache which is the default cache in Django and I'm learning Django Cache:
from django....
0
votes
0
answers
150
views
Django Cache (Redis) refresh when DB update or POST success
Is there a more efficient approach, in addition to relying solely on signals, to promptly update the Django cache in Redis whenever a modification occurs in the database?
I have explored the use of ...
2
votes
1
answer
1k
views
Django Redis cache get TTL (expire time)
Is it possible to get key's expire time in Django using Redis cache?
Something like:
from django.core.cache import cache
cache.get_expire('mykey') # 300 (seconds)
I tried:
cache.ttl('my_key')
...
2
votes
0
answers
337
views
Does Django open and close connection to cache every time I call cache.delete(key)?
Consider the following code snippet:
from django.core.cache import cache
cache.delete('key_1')
cache.delete('key_2')
If i'm using an Instance of Redis as my default cache, will Django create two ...
1
vote
1
answer
363
views
How do I delete the django cache database table?
I have been using django's database caching as shown here:
https://docs.djangoproject.com/en/4.1/topics/cache/#database-caching
Recently I have migrated to redis caching, but I still have the cache ...
0
votes
0
answers
404
views
Cache control in Nginx+Django
I have a server on Nginx. It is written with Django and connected to Nginx through Waitress. I have set up a cache in Nginx. My server has both dynamic and static pages.
After starting a server, it ...
1
vote
1
answer
1k
views
While using Cache In DRF after using POST request new data is not being displayed on client side
I have implemented cache for my articles views, and have set cache page. Currently the issue that i am facing is when i try to POST request data to create new article, the page remains the same.
What ...
10
votes
2
answers
2k
views
Since django 4.1, templates are cached with DEBUG=True. Is this solution right?
As described in the documentation, since 4.1 the default behavior for template loading changed drastically.
If I understand it right, until 4.0 it worked like this:
With DEBUG enabled, the templates ...
2
votes
0
answers
873
views
django 3.0.2 get_cache_key returns different cache keys
I'm trying to invalidate a view following this Expire a view-cache in Django?.
Here's a view function where I have disabled per-site caching and enabled per-view caching.
This is the view, say, that I ...