Changed some formatting in docs/middleware.txt

git-svn-id: http://code.djangoproject.com/svn/django/trunk@814 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-10-09 01:08:58 +00:00
parent fd4ddb179f
commit 22bbdc633c
1 changed files with 59 additions and 45 deletions

View File

@ -45,24 +45,30 @@ required.
Available middleware Available middleware
==================== ====================
``django.middleware.admin.AdminUserRequired`` django.middleware.admin.AdminUserRequired
Limits site access to valid users with the ``is_staff`` flag set. This is -----------------------------------------
required by Django's admin, and this middleware requires ``SessionMiddleware``.
``django.middleware.cache.CacheMiddleware`` Limits site access to valid users with the ``is_staff`` flag set. This is
Enables site-wide cache. If this is enabled, each Django-powered page will be required by Django's admin, and this middleware requires ``SessionMiddleware``.
cached for as long as the ``CACHE_MIDDLEWARE_SECONDS`` setting defines. See
the `cache documentation`_.
.. _`cache documentation`: http://www.djangoproject.com/documentation/cache/#the-per-site-cache django.middleware.cache.CacheMiddleware
---------------------------------------
``django.middleware.common.CommonMiddleware`` Enables site-wide cache. If this is enabled, each Django-powered page will be
Adds a few conveniences for perfectionists: cached for as long as the ``CACHE_MIDDLEWARE_SECONDS`` setting defines. See
the `cache documentation`_.
* Forbids access to user agents in the ``DISALLOWED_USER_AGENTS`` setting, .. _`cache documentation`: http://www.djangoproject.com/documentation/cache/#the-per-site-cache
django.middleware.common.CommonMiddleware
-----------------------------------------
Adds a few conveniences for perfectionists:
* Forbids access to user agents in the ``DISALLOWED_USER_AGENTS`` setting,
which should be a list of strings. which should be a list of strings.
* Performs URL rewriting based on the ``APPEND_SLASH`` and ``PREPEND_WWW`` * Performs URL rewriting based on the ``APPEND_SLASH`` and ``PREPEND_WWW``
settings. If ``APPEND_SLASH`` is ``True``, URLs that lack a trailing settings. If ``APPEND_SLASH`` is ``True``, URLs that lack a trailing
slash will be redirected to the same URL with a trailing slash. If slash will be redirected to the same URL with a trailing slash. If
``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be ``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be
@ -74,36 +80,44 @@ Available middleware
indexer would treat them as separate URLs -- so it's best practice to indexer would treat them as separate URLs -- so it's best practice to
normalize URLs. normalize URLs.
* Handles ETags based on the ``USE_ETAGS`` setting. If ``USE_ETAGS`` is set * Handles ETags based on the ``USE_ETAGS`` setting. If ``USE_ETAGS`` is set
to ``True``, Django will calculate an ETag for each request by to ``True``, Django will calculate an ETag for each request by
MD5-hashing the page content, and it'll take care of sending MD5-hashing the page content, and it'll take care of sending
``Not Modified`` responses, if appropriate. ``Not Modified`` responses, if appropriate.
* Handles flat pages. Every time Django encounters a 404 -- either within * Handles flat pages. Every time Django encounters a 404 -- either within
a view or as a result of no URLconfs matching -- it will check the a view or as a result of no URLconfs matching -- it will check the
database of flat pages based on the current URL. database of flat pages based on the current URL.
``django.middleware.doc.XViewMiddleware`` django.middleware.doc.XViewMiddleware
Sends custom ``X-View`` HTTP headers to HEAD requests that come from IP -------------------------------------
addresses defined in the ``INTERNAL_IPS`` setting. This is used by Django's
automatic documentation system.
``django.middleware.gzip.GZipMiddleware`` Sends custom ``X-View`` HTTP headers to HEAD requests that come from IP
Compresses content for browsers that understand gzip compression (all addresses defined in the ``INTERNAL_IPS`` setting. This is used by Django's
modern browsers). automatic documentation system.
``django.middleware.http.ConditionalGetMiddleware`` django.middleware.gzip.GZipMiddleware
Handles conditional GET operations. If the response has a ``ETag`` or -------------------------------------
``Last-Modified`` header, and the request has ``If-None-Match`` or
``If-Modified-Since``, the response is replaced by an HttpNotModified.
Also removes the content from any response to a HEAD request and sets the Compresses content for browsers that understand gzip compression (all modern
``Date`` and ``Content-Length`` response-headers. browsers).
``django.middleware.sessions.SessionMiddleware`` django.middleware.http.ConditionalGetMiddleware
Enables session support. See the `session documentation`_. -----------------------------------------------
.. _`session documentation`: http://www.djangoproject.com/documentation/sessions/ Handles conditional GET operations. If the response has a ``ETag`` or
``Last-Modified`` header, and the request has ``If-None-Match`` or
``If-Modified-Since``, the response is replaced by an HttpNotModified.
Also removes the content from any response to a HEAD request and sets the
``Date`` and ``Content-Length`` response-headers.
django.middleware.sessions.SessionMiddleware
--------------------------------------------
Enables session support. See the `session documentation`_.
.. _`session documentation`: http://www.djangoproject.com/documentation/sessions/
Writing your own middleware Writing your own middleware
=========================== ===========================