Questions tagged [django-cache]

Django includes a cache system that lets you save dynamic pages or page fragments so they don't have to be generated for each request.

Django comes with a robust cache system that lets you save dynamic pages so they don't have to be calculated for each request. For convenience, Django offers different levels of cache granularity: You can cache the output of specific views, you can cache only the pieces that are difficult to produce, or you can cache your entire site.

Django also works well with "upstream" caches, such as Squid and browser-based caches. These are the types of caches that you don't directly control but to which you can provide hints (via HTTP headers) about which parts of your site should be cached, and how.

See also:

248 questions
0
votes
0 answers

Updating the Django cache programmatically

I plan to cache some of my endpoints powered by DRF, and I want to update the cache wherever it is appropriate. So basically I need to somehow understand what key corresponds to the given cache. As far as I understand, Django does not provide such…
Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121
0
votes
0 answers

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 I finish using cache in Django Views as shown…
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
0
votes
0 answers

How to get the expiration times of cache values properly in Django?

I set 3 cache values with timeout and get the expiration times with cache._expire_info in LocMemCache as shown below: from django.core.cache import cache cache.set("name", "John", timeout=60) cache.set("age", 36, timeout=120) cache.set("gender",…
0
votes
0 answers

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 signals, but I discovered that they clear the…
0
votes
0 answers

Why is my cache not invalidated when using cachalot and Django?

My project uses Django version 4.1.9 and cachalot 2.5.3 (latest version). I just added the CACHES (BACKEND: "django.core.cache.backends.redis.RedisCache") option in Django and added the UpdateCacheMiddleware and FetchFromCacheMiddleware middlewares…
creyD
  • 1,972
  • 3
  • 26
  • 55
0
votes
0 answers

Django: Is it a good idea to have two caches on one memcached instance?

I would like to have two caches with different timeouts on one memcached instance in my django 3 instance: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', …
user1383029
  • 1,685
  • 2
  • 19
  • 37
0
votes
0 answers

Deleting many object from cache fulfilling given condition

I've got model X constructed per other model Y and user U. X is stored in django-cache under key 'X_Y.id_U.id'. Now i want to delete all models X binded to Y from cache (for all users). How can i do this well?
santino
  • 159
  • 2
  • 11
0
votes
0 answers

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 table in my database from the command python…
Mathijs
  • 177
  • 3
  • 18
0
votes
0 answers

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 caches only static pages(correct behaviour for me),…
Kenion
  • 27
  • 4
0
votes
0 answers

SessionId inside the cookie header slows down response (Django)

I'm learning how to use django sessions and caching. I noticed that once I login, a sessionId is included in the cookie header. I'm using the "@authentication_classes" and "@permission_classes" decorators to validate the session. I'm also using…
0
votes
0 answers

Django Query "caches" until restarting Server

Django "caches" my query. I realized it after updating my Database. When i run the Function with the Query, it takes some old Data before the Update. When i restart the Server, it works fine again. Do anyone know, how i can solve this issue? I use…
0
votes
1 answer

Efficient storing a big table in Django cache

I use Django with jqGrid and loading pages via AJAX. At times, queries are very complex, and page loading is ver slow, for far pages is much slower (which is to be expected, the results often exceed 100k objects). I thought that result caching will…
janek37
  • 572
  • 5
  • 16
0
votes
1 answer

Django: never_cache is not working, it still shows same data on browser back button

I have a create view which is used to make an object of type Course(model). i'm using never_cache decorator to reload the page from server everytime i use it. now if i create a course it gets added in the Course database, now if i press browser back…
0
votes
1 answer

Cannot load translation catalog for Django I18n on Google App Engine Standard

I've set up I18n for my Python3 Django4.0 app and it runs locally without problems. When I deploy it to GAE standard the translated text isn't shown. The active language changes, but the text does not change. The catalog files exist, but it looks…
John
  • 949
  • 1
  • 9
  • 20
0
votes
0 answers

DRF - Inconsistency in Throttling

Hi I am facing extreme inconsistency in Throttling mechanism in Django rest framework. I have the api endpoint to throttle 10 requests/sec but when I send 20 requests at the same time using Apache Benchmark the api should throttle 10 requests…