Questions tagged [django-caching]

django-caching refers to the Django cache system

django-caching refers to the Django cache system.

Quote from docs:

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.

57 questions
41
votes
12 answers

Get list of Cache Keys in Django

I'm trying to understand how Django is setting keys for my views. I'm wondering if there's a way to just get all the saved keys from Memcached. something like a cache.all() or something. I've been trying to find the key with cache.has_key('test')…
Brenden
  • 8,264
  • 14
  • 48
  • 78
35
votes
4 answers

How to clear the whole cache when using django's page_cache decorator?

I've got a pretty simple site where I'm using the page_cache decorator. I have a cronjob that checks for new data and processes it if it's available. (This is run using management commands executed with crontab) I want to then clear all the page…
monkut
  • 42,176
  • 24
  • 124
  • 155
28
votes
6 answers

How to use 2 different cache backends in Django?

I need to use memcached and file based cache. I setup my cache in settings: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': 'c:/foo/bar', }, 'inmem': { …
robos85
  • 2,484
  • 5
  • 32
  • 36
26
votes
5 answers

Clearing specific cache in Django

I am using view caching for a django project. It says the cache uses the URL as the key, so I'm wondering how to clear the cache of one of the keys if a user updates/deletes the object. An example: A user posts a blog post to domain.com/post/1234/…
Brenden
  • 8,264
  • 14
  • 48
  • 78
13
votes
2 answers

Contents of locmem cache in Django?

I was trying to use the locmem cache for my web application but couldn't find any documentation on how to see the contents of the cache. I mean I want to check if my keys are being set correctly in the cache. How can I list all the keys in this…
Mayank
  • 357
  • 3
  • 17
11
votes
3 answers

How to match redis key patterns using native django cache?

I have a series of caches which follow this pattern: key_x_y = value Like: 'key_1_3' = 'foo' 'key_2_5' = 'bar' 'key_1_7' = 'baz' Now I'm wondering how can I iterate over all keys to match pattern like key_1_* to get foo and baz using the…
Jand
  • 2,527
  • 12
  • 36
  • 66
9
votes
3 answers

How to invalidate cache_page in Django?

Here is the problem: I have blog app and I cache the post output view for 5 minutes. @cache_page(60 * 5) def article(request, slug): ... However, I'd like to invalidate the cache whenever a new comment is added to the post. I'm wondering how…
Jand
  • 2,527
  • 12
  • 36
  • 66
8
votes
2 answers

Django - Template rendering performance (I think) how to check if enabling LocMemCache is working?

Ive noticed that randomly some pages take from 2 to 12 seconds to load, I have Debug toolbar installed and I know my queries are all efficient (i.e. no duplicates) and toolbar shows they are all running in milliseconds. One particular page ive…
AlexW
  • 2,843
  • 12
  • 74
  • 156
7
votes
3 answers

Django - Multiple Sites Site Caching

I have a number of sites under one Django application that I would like to implement site wide caching on. However it is proving to be a real hassle. what happens is that settings.CACHE_MIDDLEWARE_KEY_PREFIX is set once on startup, and I cannot go…
Werda
  • 279
  • 1
  • 3
  • 9
6
votes
1 answer

django cache REST API Urls issue

I have followed the solution provided in Stack overflow Link & it is working perfectly when i use this from my browser. However, when i tried hitting that url with curl, it doesn't cache for the browser.. Let me explain. If i hit a url like…
Agam Banga
  • 2,708
  • 1
  • 11
  • 18
6
votes
3 answers

Django static files are not updated

In my Django project the application my_app has a template which references a javascript static file: Once I installed my_script.js in my_app/templates/my_app, everything seemed to work. At…
jazzblue
  • 2,411
  • 4
  • 38
  • 63
4
votes
2 answers

How use Django Cache in view without cache all page

I trying to use Django Cache to make better my views. Works great, 400ms to 8ms is perfect. But when user access page for the first time, Django cache page with user info in header and when I try log out, page continue with user info. I try use…
GIA
  • 1,400
  • 2
  • 21
  • 38
4
votes
1 answer

Cache for everybody except staff members

I have a django site where I want to stick an "admin bar" along the top of every non-admin page for staff members. It would contain useful things like page editing tools, etc. The problem comes from me using the @cache_page decorator on lots of…
Oli
  • 235,628
  • 64
  • 220
  • 299
4
votes
1 answer

Django shell doesn't respect cache configuration

In my settings.py I have: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'ws_cache_table', 'TIMEOUT': '3000000', 'OPTIONS': { 'MAX_ENTRIES': 10000000 …
mnowotka
  • 16,430
  • 18
  • 88
  • 134
3
votes
1 answer

Django Cache - Update when model changed

I can't seem to find any tutorial on how to do this. So, I basically want to add caching to my Django project. I made a blog view, that should be cached and updated only if the model got changed since last caching. How do I do this?
Myzel394
  • 1,155
  • 3
  • 16
  • 40
1
2 3 4