| | 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 |
| | 1081 | are two simple ways to exclude them. |
| | 1082 | |
| | 1083 | If only a small fraction of your traffic is generated by authenticated users, you may just |
| | 1084 | set the :setting:`CACHE_MIDDLEWARE_ANONYMOUS_ONLY`setting to ``True``. |
| | 1085 | See the :ref:`cache documentation <topics-cache>` for more information. |
| | 1086 | |
| | 1087 | Other solution is to tell Django not to cache the whole admin subtree, using decorator at |
| | 1088 | URLs 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 | |