-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Il 15/01/2013 14:23, Andrea Ambu ha scritto: > Ciao! > > Dunque si puo` facilmente controllare la max_age per una view cosi`: > > """"""""""" > from django.views.decorators.cache import cache_control > > @cache_control(max_age=3600) > def my_view(request): > # ... > > """"""""""" > > Ma se volessi che il valore di max_age venga deciso _dentro_ my_view > come posso fare? >
Dovresti leggere la specifica del protocollo HTTP, se vuoi sviluppare applicazioni web: http://tools.ietf.org/html/rfc2616#section-14.9 Mi aspetto (ed è così) che il middleware di Django onori l'header Cache-Control, magari (ma non è così) con una estensione per limitare il caching internamente (e non inviare l'header al client). Nel dubbio basta leggere il codice sorgente: django/views/decorators/cache.py e django/utils/cache.py > Per esempio: > """"""""""" > def my_view(request): > if is_good_to_keep_in_cache_for_a_bit(request): request['Cache-Control'] = 'max-age=3600' > # set max_age to 36000 > else: > # set max_age to 42 request['Cache-Control'] = 'max-age=42' > # ... > """"""""""" > Ciao Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlD1XaYACgkQscQJ24LbaUSkBgCdGpfyolXjBbyVcQsoK4lpG1MU x0oAn0kWgfUSCjNyrCSltZf9oeYAWtZl =PQeC -----END PGP SIGNATURE----- _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python