<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">Ciao!</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Dunque si puo` facilmente controllare la max_age per una view cosi`:</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">"""""""""""</div><div style="font-family:arial,sans-serif;font-size:13px">

from django.views.decorators.cache import cache_control</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">@cache_control(max_age=3600)</div><div style="font-family:arial,sans-serif;font-size:13px">

def my_view(request):</div><div style="font-family:arial,sans-serif;font-size:13px">    # ...</div><div style="font-family:arial,sans-serif;font-size:13px"><br>"""""""""""<br>

</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Ma se volessi che il valore di max_age venga deciso _dentro_ my_view come posso fare?</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Per esempio:</div><div style="font-family:arial,sans-serif;font-size:13px">"""""""""""<br>

</div><div style="font-family:arial,sans-serif;font-size:13px">def my_view(request):</div><div style="font-family:arial,sans-serif;font-size:13px">    if is_good_to_keep_in_cache_for_a_bit(request):</div><div style="font-family:arial,sans-serif;font-size:13px">

        # set max_age to 36000</div><div style="font-family:arial,sans-serif;font-size:13px">    else:</div><div style="font-family:arial,sans-serif;font-size:13px">        # set max_age to 42 </div><div style="font-family:arial,sans-serif;font-size:13px">

    # ... </div><span style="font-family:arial,sans-serif;font-size:13px">"""""""""""</span><div style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>

Cheers,</div><div>Andrea</div></div></div>