Changeset 814
- Timestamp:
- 10/08/05 20:08:58 (3 years ago)
- Files:
-
- django/trunk/docs/middleware.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/middleware.txt
r810 r814 46 46 ==================== 47 47 48 ``django.middleware.admin.AdminUserRequired`` 49 Limits site access to valid users with the ``is_staff`` flag set. This is 50 required by Django's admin, and this middleware requires ``SessionMiddleware``. 48 django.middleware.admin.AdminUserRequired 49 ----------------------------------------- 51 50 52 ``django.middleware.cache.CacheMiddleware`` 53 Enables site-wide cache. If this is enabled, each Django-powered page will be 54 cached for as long as the ``CACHE_MIDDLEWARE_SECONDS`` setting defines. See 55 the `cache documentation`_. 51 Limits site access to valid users with the ``is_staff`` flag set. This is 52 required by Django's admin, and this middleware requires ``SessionMiddleware``. 56 53 57 .. _`cache documentation`: http://www.djangoproject.com/documentation/cache/#the-per-site-cache 54 django.middleware.cache.CacheMiddleware 55 --------------------------------------- 58 56 59 ``django.middleware.common.CommonMiddleware`` 60 Adds a few conveniences for perfectionists: 57 Enables site-wide cache. If this is enabled, each Django-powered page will be 58 cached for as long as the ``CACHE_MIDDLEWARE_SECONDS`` setting defines. See 59 the `cache documentation`_. 61 60 62 * Forbids access to user agents in the ``DISALLOWED_USER_AGENTS`` setting, 63 which should be a list of strings. 61 .. _`cache documentation`: http://www.djangoproject.com/documentation/cache/#the-per-site-cache 64 62 65 * Performs URL rewriting based on the ``APPEND_SLASH`` and ``PREPEND_WWW`` 66 settings. If ``APPEND_SLASH`` is ``True``, URLs that lack a trailing 67 slash will be redirected to the same URL with a trailing slash. If 68 ``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be 69 redirected to the same URL with a leading "www." 63 django.middleware.common.CommonMiddleware 64 ----------------------------------------- 70 65 71 Both of these options are meant to normalize URLs. The philosophy is that 72 each URL should exist in one, and only one, place. Technically a URL 73 ``foo.com/bar`` is distinct from ``foo.com/bar/`` -- a search-engine 74 indexer would treat them as separate URLs -- so it's best practice to 75 normalize URLs. 66 Adds a few conveniences for perfectionists: 76 67 77 * Handles ETags based on the ``USE_ETAGS`` setting. If ``USE_ETAGS`` is set 78 to ``True``, Django will calculate an ETag for each request by 79 MD5-hashing the page content, and it'll take care of sending 80 ``Not Modified`` responses, if appropriate. 68 * Forbids access to user agents in the ``DISALLOWED_USER_AGENTS`` setting, 69 which should be a list of strings. 81 70 82 * Handles flat pages. Every time Django encounters a 404 -- either within 83 a view or as a result of no URLconfs matching -- it will check the 84 database of flat pages based on the current URL. 71 * Performs URL rewriting based on the ``APPEND_SLASH`` and ``PREPEND_WWW`` 72 settings. If ``APPEND_SLASH`` is ``True``, URLs that lack a trailing 73 slash will be redirected to the same URL with a trailing slash. If 74 ``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be 75 redirected to the same URL with a leading "www." 85 76 86 ``django.middleware.doc.XViewMiddleware`` 87 Sends custom ``X-View`` HTTP headers to HEAD requests that come from IP 88 addresses defined in the ``INTERNAL_IPS`` setting. This is used by Django's 89 automatic documentation system. 77 Both of these options are meant to normalize URLs. The philosophy is that 78 each URL should exist in one, and only one, place. Technically a URL 79 ``foo.com/bar`` is distinct from ``foo.com/bar/`` -- a search-engine 80 indexer would treat them as separate URLs -- so it's best practice to 81 normalize URLs. 90 82 91 ``django.middleware.gzip.GZipMiddleware`` 92 Compresses content for browsers that understand gzip compression (all 93 modern browsers). 83 * Handles ETags based on the ``USE_ETAGS`` setting. If ``USE_ETAGS`` is set 84 to ``True``, Django will calculate an ETag for each request by 85 MD5-hashing the page content, and it'll take care of sending 86 ``Not Modified`` responses, if appropriate. 94 87 95 ``django.middleware.http.ConditionalGetMiddleware`` 96 Handles conditional GET operations. If the response has a ``ETag`` or 97 ``Last-Modified`` header, and the request has ``If-None-Match`` or 98 ``If-Modified-Since``, the response is replaced by an HttpNotModified. 88 * Handles flat pages. Every time Django encounters a 404 -- either within 89 a view or as a result of no URLconfs matching -- it will check the 90 database of flat pages based on the current URL. 99 91 100 Also removes the content from any response to a HEAD request and sets the101 ``Date`` and ``Content-Length`` response-headers. 92 django.middleware.doc.XViewMiddleware 93 ------------------------------------- 102 94 103 ``django.middleware.sessions.SessionMiddleware`` 104 Enables session support. See the `session documentation`_. 95 Sends custom ``X-View`` HTTP headers to HEAD requests that come from IP 96 addresses defined in the ``INTERNAL_IPS`` setting. This is used by Django's 97 automatic documentation system. 105 98 106 .. _`session documentation`: http://www.djangoproject.com/documentation/sessions/ 99 django.middleware.gzip.GZipMiddleware 100 ------------------------------------- 101 102 Compresses content for browsers that understand gzip compression (all modern 103 browsers). 104 105 django.middleware.http.ConditionalGetMiddleware 106 ----------------------------------------------- 107 108 Handles conditional GET operations. If the response has a ``ETag`` or 109 ``Last-Modified`` header, and the request has ``If-None-Match`` or 110 ``If-Modified-Since``, the response is replaced by an HttpNotModified. 111 112 Also removes the content from any response to a HEAD request and sets the 113 ``Date`` and ``Content-Length`` response-headers. 114 115 django.middleware.sessions.SessionMiddleware 116 -------------------------------------------- 117 118 Enables session support. See the `session documentation`_. 119 120 .. _`session documentation`: http://www.djangoproject.com/documentation/sessions/ 107 121 108 122 Writing your own middleware
