title: How to disable Django Internal function cache?
body: <p>I'm making some Django projects using Redis as Backend Cache[1], but I can't be sure that the Redis Server will be On all the time, then I'm trying to use Redis "if" it's available otherwise use some other Backend like LocMem and so on.</p>
  
  <p>The Redis Backend that I'm using[1] is full compatible so I can use Django Decorations.</p>
  
  <p>I was think to create a function to be called like that:</p>
  
  <pre><code>from django.views.decorators.cache import cache_page
  from utils import PingBackend
  from time import time
  
  @cache_page(60, cache=PingBackend(time()))
  def index(request):
  
      artigos = Artigo.objects.filter(ativo=1)
  
      return render_to_response('index.html', {'artigos':artigos}, RequestContext(request))
  </code></pre>
  
  <p>The problem is that Django (Internals I guess) Caches the response of PingBackend() and call it just the first time, even if I drop the RedisServer Django tells that the ping process was successfully.</p>
  
  <p>It occurs even with DEBUG=True and 'default' CacheBackend to dummy.</p>
  
  <pre><code>def PingBackend(time):
      print time
  
      response = None
  
      try:
          con = StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
  
          # Execute some action
          con.ping()
  
          # If not give an exception, use redis
          response = 'redis'
  
      except:
          response = 'default' #dummy
  
      return last_response
  </code></pre>
  
  <p>I'm passing time() just to create some differentiation as a try solve the cache problm.</p>
  
  <p>The big picture is that the function PingBackend() aren't executing for each request, just for the first the I can't monitor the Redis Server.</p>
  
  <p>Thank you!</p>
  
  <p>[1] - <a href="https://github.com/niwibe/django-redis" rel="nofollow">https://github.com/niwibe/django-redis</a> </p>