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
1
vote
1 answer

Django's cache clear function does not work on view cache?

I am using the view cache for Django 1.10. But I am having problems clearing the cache. @cache_page(60 * 30, cache="container_table") def container_table(request, dataset): # determine container_list by a query to the database return…
ilikecats
  • 199
  • 1
  • 3
  • 17
1
vote
1 answer

Django Moving lookup table to Redis

I have a django app with redis which is currently used as the broker for Celery, and nothing beyond that. I would like to utilize it further for lookup caching. Let's say I had a widely used table in my database that I keep hitting for lookups.…
JasonGenX
  • 4,952
  • 27
  • 106
  • 198
1
vote
2 answers

how to achieve faster tfidfvectorizer loading times from within a django view?

I have a fitted TfidfVectorizer with ~120,000 features which I save to file using joblib.dump. I later load that model, from within a django view, using joblib.load but it is too slow (takes ~2 seconds). What is the best way to improve the loading…
jkarimi
  • 1,247
  • 2
  • 15
  • 27
1
vote
1 answer

Django queryset filter performance

I have a queryset :- queryset = my_object.someobject_set.all() From there onwards, I want to filter from the queryset. i.e: print queryset.filter(name='some1').exists() print queryset.filter(name='some2').exists() print…
1
vote
1 answer

weak object has gone away? - python/django

I'm having this problem in my django project that I believe is related to caches. It appears once every 6 months or so and is "fixed" by restarting the app, only to come back some months later. Suddenly all views will fail with this…
Martin Massera
  • 1,718
  • 1
  • 21
  • 47
1
vote
1 answer

django-pipeline wipes out my entries in Django Database Cache

I'm working on a Django application which uses django-pipeline for dealing with browsers' file caching issues (and also for other benefits). STATIC_URL = '/static/' STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' STATICFILES_DIRS =…
Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
1
vote
0 answers

Django join on cached queryset

I have three models: class Video(models.Model): video_pk = models.AutoField(primary_key=True) author_fk = models.ForeignKey(GRUser, related_name='uploaded_videos', db_column='author_fk') class VideoLike(models.Model): video_like_pk =…
Lev
  • 104
  • 1
  • 12
1
vote
0 answers

Using Django Cache with Celery + Redis Causes Celery to Crash

I have a Python app running on Heroku and I have Redis and Celery working but when I try to configure Django Cache (which makes my app run much faster), it causes Celery to constantly crash. Here is what I see in my logs after enabling Django…
1
vote
1 answer

Exclude middleware from caching

I have very simple middleware that track numbers of "hits" of an object. class HitCount(): def process_view(self, request, view_func, view_args, view_kwargs): if request.resolver_match.url_name == 'article_view': try: …
m51
  • 1,950
  • 16
  • 25
1
vote
1 answer

Django pagination while objects are being added

I've got a website that shows photos that are always being added and people are seeing duplicates between pages on the home page (last added photos) I'm not entirely sure how to approach this problem but this is basically whats happening: Home page…
davegri
  • 2,206
  • 2
  • 26
  • 45
1
vote
0 answers

Wierd caching behaviour in django

I am using django's local memory cache (django.core.cache.backends.locmem.LocMemCache) and using tastypie for REST API. I have following code in CommentResource object in file api.py: def get_object_list(self, request): cached_comments =…
kamalbanga
  • 1,881
  • 5
  • 27
  • 46
1
vote
1 answer

Django: cache a dictionary containing a lambda function

I am trying to save a dictionary that contains a lambda function in django.core.cache. The example below fails silently. from django.core.cache import cache cache.set("lambda", {"name": "lambda function", "function":lambda x:…
ahmohamed
  • 2,920
  • 20
  • 35
1
vote
1 answer

using multiple cache backends at the same time

We want to switch from memcachedb to redis. As the site has very high usage and the caching is kind of critical, we wanted to see if it is possible to make a test-deploy with both memcachedb and redis running. Only once we confirmed that all keys…
1
vote
1 answer

Django's query result caching

I am creating a website using Django 1.7 and GeoDjango. I've hit the point when i need to optimize website speed. One of the bottlenecks is query execution. There are some queries which run slowly even when optimized. So i'd like to cache query…
Termos
  • 664
  • 1
  • 7
  • 31
1
vote
1 answer

Django Caching with Users

I was wondering if there is a way to cache querysets to memcache on a site that has authenticated users and users that are not authenticated. Basically I just need to cache queries from one table. Any ideas would be great. Thanks
icebox3d
  • 449
  • 7
  • 17