Ticket #9709: django-admin-and-caching-docs.patch

File django-admin-and-caching-docs.patch, 1.9 KB (added by Michał Sałaban, 16 years ago)
  • docs/faq/admin.txt

     
    3131How can I prevent the cache middleware from caching the admin site?
    3232-------------------------------------------------------------------
    3333
    34 Set the :setting:`CACHE_MIDDLEWARE_ANONYMOUS_ONLY` setting to ``True``. See the
    35 :ref:`cache documentation <topics-cache>` for more information.
     34See :ref:`AdminSite and caching <admin-and-caching>` documentation.
    3635
    3736How do I automatically set a field's value to the user who last edited the object in the admin?
    3837-----------------------------------------------------------------------------------------------
  • docs/ref/contrib/admin.txt

     
    10711071        ('^basic-admin/(.*)', basic_site.root),
    10721072        ('^advanced-admin/(.*)', advanced_site.root),
    10731073    )
     1074
     1075.. _admin-and-caching:
     1076
     1077``AdminSite`` and ``caching``
     1078=============================
     1079
     1080``AdminSite`` is a set of pages which you probably do not want to cache at all. There
     1081are two simple ways to exclude them.
     1082
     1083If only a small fraction of your traffic is generated by authenticated users, you may just
     1084set the :setting:`CACHE_MIDDLEWARE_ANONYMOUS_ONLY`setting to ``True``.
     1085See the :ref:`cache documentation <topics-cache>` for more information.
     1086
     1087Other solution is to tell Django not to cache the whole admin subtree, using decorator at
     1088URLs configuration::
     1089
     1090    # urls.py
     1091    from django.conf.urls.defaults import *
     1092    from django.contrib import admin
     1093    from django.views.decorators.cache import never_cache
     1094
     1095    admin.autodiscover()
     1096
     1097    urlpatterns = patterns('',
     1098        ('^admin/(.*)', never_cache(admin.site.root)),
     1099    )
     1100
Back to Top