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

How to cache django views only for unauthenticated users?

I'd like to cache certain views/pages for unauthenticated users but django cache_page does not seem to have such option. So wonderin how best can I achieve this?
Jand
  • 2,527
  • 12
  • 36
  • 66
0
votes
1 answer

Can not cache queryset in Django

In a views I have this cache which is supposed to save some costly queries: from django.core.cache import cache LIST_CACHE_TIMEOUT = 120 .... topics = cache.get('forum_topics_%s' % forum_id) if not topics: topics =…
Jand
  • 2,527
  • 12
  • 36
  • 66
0
votes
1 answer

How to cache a list of requests in Django views?

I'd like to keep the list of 'Last Seen' 20 requests into a Django view. Also I want to avoid creating a separate model for it and just keep the requested urls in memcached, by pushing each new request to a fixed size queue and then retrieve the…
Jand
  • 2,527
  • 12
  • 36
  • 66
0
votes
1 answer

Clear Django view cache on logout

I'm cacheing a view as below: @cache_page(60 * 15) def my_view(request): # Get results for request.user return HttpResponse(json.dumps(results), content_type="application/json", status=200) How can I clear this cache when the user logs out?
greenafrican
  • 2,516
  • 5
  • 27
  • 38
0
votes
1 answer

Django - queryset caching request-independent?

I need to cache a mid-sized queryset (about 500 rows). I had a look on some solutions, django-cache-machine being the most promising. Since the queryset is pretty much static (it's a table of cities that's been populated in advance and gets updated…
mp85
  • 422
  • 3
  • 17
0
votes
1 answer

After adding Django CMS to my project, management commands fail with a cache error. How can I fix it?

This is using Django 1.7 and Django CMS 3.1.0. I've had a large Django project that has been in production for months without any issue. I'm currently adding Django CMS to it and found that if my cache is offline, I cannot issue any management…
Louis
  • 146,715
  • 28
  • 274
  • 320
0
votes
1 answer

how can I cache get_or_create tuple - django

how can I cache the obj (not the created) obj, created = MyModel.objects.get_or_create(id=someid) I cannot do: cached_tuple = cache.set('cachekey', obj, created, 600) any ideas?
doniyor
  • 36,596
  • 57
  • 175
  • 260
0
votes
1 answer

django cache query result for templates and views

I want to cache a query result on per request basis. Because I need that query in multiple places. And I want to cache that query on request and use it whenever and wherever I want. And at the end of the request-response cycle it should expire .…
Vaibhav Jain
  • 5,287
  • 10
  • 54
  • 114
0
votes
2 answers

Django cache everything but a piece

I'm writing a blog application. All the pages (lists of posts, detail of the post) are really static, I can predict when the must be update (for example when I write a new post or a comment is added). I could use @cache_page to cache entire…
pistacchio
  • 56,889
  • 107
  • 278
  • 420
0
votes
1 answer

Use Django sessions per view as opposed to per user

I am confused! I am trying to use Django's caching system to store some data so that it is accessible throughout the GET/PUT of the main view as well as several potential AJAX views while the user is interacting w/ the page. I thought that I would…
trubliphone
  • 4,132
  • 3
  • 42
  • 66
0
votes
1 answer

getting 304 response even with django-cors-headers

I installed django-cors-headers in my django application. I want to display svg file in webbrowser. For first time, its not loading properly and its showing 304 response in network. Can anyone help me how to rectify this problem?
CRS...
  • 95
  • 1
  • 7
0
votes
1 answer

django cache - what does this do?

I am reading django's cache framework and came across this code (not in the docs): feed = cache.get('sfc:index:%s' % request.LANGUAGE_CODE) I couldnot find this style of getting/settings caches by googling. what is the purpose of : inside cache…
doniyor
  • 36,596
  • 57
  • 175
  • 260
0
votes
1 answer

cached not being set for some data in Django memcahed

I'm using memcached as a cache backend in Django. The cache is not working for a particular view. Below is the logic of the caching in the view. >>> genre = Genre.objects.get(id=1) >>> genre_song_list = Song.objects.filter(genres=genre,…
Yin Yang
  • 1,776
  • 3
  • 26
  • 48
0
votes
1 answer

How change caching setting in django_cache_utils0.7 to cache the files in different directory other than C drive?

I am using django-cache-utils 0.7 where I am not able to change the cache directory to a drive location other than the default location. Please can anyone tell me how to define custom location and set a size limit on the folder ? CACHE_BACKEND =…
Sohail.py
  • 3
  • 2
0
votes
0 answers

Django get_cache_key works with database backend but not with filesystem

I'm facing a curious behaviour when trying to use Django filesystem caching backend. When trying to find a per view cache key, I do something like this: request = HttpRequest() request.path = obj.get_absolute_url() key = get_cache_key(request) With…
user650108
  • 1,009
  • 1
  • 9
  • 18
1 2 3
16
17