|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/lib64/python2.7/site-packages/django/middleware/ |
Upload File : |
�
r�\c @ s� d Z d d l Z d d l m Z d d l m Z m Z d d l m Z m Z m
Z
m Z m Z d e
f d � � YZ d e
f d � � YZ d
e e f d � � YZ d S( s�
Cache middleware. If enabled, each Django-powered page will be cached based on
URL. The canonical way to enable cache middleware is to set
``UpdateCacheMiddleware`` as your first piece of middleware, and
``FetchFromCacheMiddleware`` as the last::
MIDDLEWARE_CLASSES = [
'django.middleware.cache.UpdateCacheMiddleware',
...
'django.middleware.cache.FetchFromCacheMiddleware'
]
This is counter-intuitive, but correct: ``UpdateCacheMiddleware`` needs to run
last during the response phase, which processes middleware bottom-up;
``FetchFromCacheMiddleware`` needs to run last during the request phase, which
processes middleware top-down.
The single-class ``CacheMiddleware`` can be used for some simple sites.
However, if any other piece of middleware needs to affect the cache key, you'll
need to use the two-part ``UpdateCacheMiddleware`` and
``FetchFromCacheMiddleware``. This'll most often happen when you're using
Django's ``LocaleMiddleware``.
More details about how the caching works:
* Only GET or HEAD-requests with status code 200 are cached.
* The number of seconds each page is stored for is set by the "max-age" section
of the response's "Cache-Control" header, falling back to the
CACHE_MIDDLEWARE_SECONDS setting if the section was not found.
* This middleware expects that a HEAD request is answered with the same response
headers exactly like the corresponding GET request.
* When a hit occurs, a shallow copy of the original response object is returned
from process_request.
* Pages will be cached based on the contents of the request headers listed in
the response's "Vary" header.
* This middleware also sets ETag, Last-Modified, Expires and Cache-Control
headers on the response object.
i����N( t settings( t get_cachet DEFAULT_CACHE_ALIAS( t
get_cache_keyt get_max_aget has_vary_headert learn_cache_keyt patch_response_headerst UpdateCacheMiddlewarec B s2 e Z d Z d � Z d � Z d � Z d � Z RS( s>
Response-phase cache middleware that updates the cache if the response is
cacheable.
Must be used as part of the two-part update/fetch cache middleware.
UpdateCacheMiddleware must be the first piece of middleware in
MIDDLEWARE_CLASSES so that it'll get called last during the response phase.
c C sO t j | _ t j | _ t t d t � | _ t j | _ t
| j � | _ d S( Nt CACHE_MIDDLEWARE_ANONYMOUS_ONLY( R t CACHE_MIDDLEWARE_SECONDSt
cache_timeoutt CACHE_MIDDLEWARE_KEY_PREFIXt
key_prefixt getattrt Falset cache_anonymous_onlyt CACHE_MIDDLEWARE_ALIASt cache_aliasR t cache( t self( ( s9 /tmp/pip-install-XxeQeY/django/django/middleware/cache.pyt __init__? s
c C s'