title: Dynamic control over cache max age at request time in Django
body: <p>In Django I can use something like this to <a href="https://docs.djangoproject.com/en/1.0/topics/cache/#controlling-cache-using-other-headers" rel="nofollow">manage cache's max-age</a> for a request:</p>
  
  <pre><code>from django.views.decorators.cache import cache_control
  
  @cache_control(max_age=3600)
  def my_view(request):
      # ...
  </code></pre>
  
  <p>How can I set a different <code>max_age</code> value <em>inside</em> the view function so that it can depend on what the <code>request</code> content is?</p>
  
  <p>Example:</p>
  
  <pre><code>def my_view(request):
      if is_good_to_cache(request):
          # set max_age to 36000
      else:
          # set max_age to 42 
      # ... 
  </code></pre>