§
    Ÿj²!  ã                   ó¸   — 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dlmZ ddlmZ  G d„ d	e¦  «        Z G d
„ de¦  «        Z G d„ dee¦  «        ZdS )aØ  
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 = [
        'django.middleware.cache.UpdateCacheMiddleware',
        ...
        'django.middleware.cache.FetchFromCacheMiddleware'
    ]

This is counterintuitive, 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.

é    N)Úsettings)ÚDEFAULT_CACHE_ALIASÚcaches)Úget_cache_keyÚget_max_ageÚhas_vary_headerÚlearn_cache_keyÚpatch_response_headers)ÚMiddlewareMixin)Úparse_http_date_safec                   óD   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zd„ Zd„ Zˆ xZ	S )ÚUpdateCacheMiddlewarea6  
    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
    so that it'll get called last during the response phase.
    c                 ó¾   •— t          ¦   «                              |¦  «         t          j        | _        d | _        t          j        | _        t          j        | _	        d S ©N)
ÚsuperÚ__init__r   ÚCACHE_MIDDLEWARE_SECONDSÚcache_timeoutÚpage_timeoutÚCACHE_MIDDLEWARE_KEY_PREFIXÚ
key_prefixÚCACHE_MIDDLEWARE_ALIASÚcache_alias©ÚselfÚget_responseÚ	__class__s     €úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/django/middleware/cache.pyr   zUpdateCacheMiddleware.__init__G   sI   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&Ý%Ô>ˆÔØ ˆÔÝ"Ô>ˆŒÝ#Ô:ˆÔÐÐó    c                 ó&   — t           | j                 S r   ©r   r   ©r   s    r   ÚcachezUpdateCacheMiddleware.cacheN   ó   € å�dÔ&Ô'Ð'r   c                 ó0   — t          |d¦  «        o|j        S )NÚ_cache_update_cache)Úhasattrr&   )r   ÚrequestÚresponses      r   Ú_should_update_cachez*UpdateCacheMiddleware._should_update_cacheR   s   € Ý�wÐ 5Ñ6Ô6ÐV¸7Ô;VÐVr   c                 óx  ‡ ‡‡— ‰                       ||¦  «        s|S |j        s	|j        dvr|S |j        s|j        rt          |d¦  «        r|S d|                     dd¦  «        v r|S t          |d¦  «        r|S ‰ j        Š‰€!t          |¦  «        Š‰€‰ j	        Šn‰dk    r|S t          |‰¦  «         ‰r„|j        d	k    ryt          ||‰‰ j        ‰ j        ¬
¦  «        Št          |d¦  «        r/t          |j        ¦  «        r|                     ˆˆ ˆfd„¦  «         n‰ j                             ‰|‰¦  «         |S )zSet the cache, if needed.)éÈ   i0  ÚCookieÚprivatezCache-Control© Ú*Nr   r,   ©r#   Úrenderc                 ó<   •— ‰j                              ‰| ‰¦  «        S r   )r#   Úset)ÚrÚ	cache_keyr   Útimeouts    €€€r   ú<lambda>z8UpdateCacheMiddleware.process_response.<locals>.<lambda>‚   s   ø€ ˜dœjŸnšn¨Y¸¸7ÑCÔC€ r   )r*   Ú	streamingÚstatus_codeÚCOOKIESÚcookiesr   Úgetr   r   r   r
   r	   r   r#   r'   Úcallabler2   Úadd_post_render_callbackr4   )r   r(   r)   r6   r7   s   `  @@r   Úprocess_responsez&UpdateCacheMiddleware.process_responseU   s   øøø€ à×(Ò(¨°(Ñ;Ô;ð 	àˆOàÔð 	 Ô!5¸ZÐ!GÐ!GØˆOð
 ”ð	àÔ ð	õ   ¨(Ñ3Ô3ð	ð
 ˆOð ˜Ÿš _°bÑ9Ô9Ð9Ð9ØˆOõ ˜8 SÑ)Ô)ð 	ØˆOð Ô#ˆØˆ?õ " (Ñ+Ô+ˆGØˆØÔ,��Ø˜A’�à�Ý˜x¨Ñ1Ô1Ð1Øð 		=�xÔ+¨sÒ2Ð2Ý'Ø˜ 7¨D¬OÀ4Ä:ðñ ô ˆIõ �x Ñ*Ô*ð =­x¸¼Ñ/HÔ/Hð =Ø×1Ò1ØCÐCÐCÐCÐCÐCñô ð ð ð ”
—’˜y¨(°GÑ<Ô<Ð<Øˆr   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr#   r*   r@   Ú__classcell__©r   s   @r   r   r   =   s~   ø€ € € € € ðð ð;ð ;ð ;ð ;ð ;ð ð(ð (ñ „Xð(ðWð Wð Wð1ð 1ð 1ð 1ð 1ð 1ð 1r   r   c                   ó>   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zd„ Zˆ xZS )ÚFetchFromCacheMiddlewarea!  
    Request-phase cache middleware that fetches a page from the cache.

    Must be used as part of the two-part update/fetch cache middleware.
    FetchFromCacheMiddleware must be the last piece of middleware in MIDDLEWARE
    so that it'll get called last during the request phase.
    c                 óŽ   •— t          ¦   «                              |¦  «         t          j        | _        t          j        | _        d S r   )r   r   r   r   r   r   r   r   s     €r   r   z!FetchFromCacheMiddleware.__init__’   s6   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&Ý"Ô>ˆŒÝ#Ô:ˆÔÐÐr   c                 ó&   — t           | j                 S r   r!   r"   s    r   r#   zFetchFromCacheMiddleware.cache—   r$   r   c                 ó"  — |j         dvr	d|_        dS t          || j        d| j        ¬¦  «        }|€	d|_        dS | j                             |¦  «        }|€B|j         dk    r7t          || j        d| j        ¬¦  «        }| j                             |¦  «        }|€	d|_        dS t          |¦  «        x}�St          |d         ¦  «        x}	 �;t          t          j	        ¦   «         ¦  «        }||z
  }t          d	||z
  ¦  «        |d
<   d|_        |S )zn
        Check whether the page is already cached and return the cached
        version if available.
        )ÚGETÚHEADFNrM   r1   TrN   ÚExpiresr   ÚAge)Úmethodr&   r   r   r#   r=   r   r   ÚintÚtimeÚmax)r   r(   r6   r)   Úmax_age_secondsÚexpires_timestampÚnow_timestampÚremaining_secondss           r   Úprocess_requestz(FetchFromCacheMiddleware.process_request›   s7  € ð
 Œ> Ð0Ð0Ø*/ˆGÔ'Ø�4õ " '¨4¬?¸EÈÌÐTÑTÔTˆ	ØÐØ*.ˆGÔ'Ø�4Ø”:—>’> )Ñ,Ô,ˆàÐ ¤°&Ò 8Ð 8Ý%Ø˜œ¨&¸¼
ðñ ô ˆIð ”z—~’~ iÑ0Ô0ˆHàÐØ*.ˆGÔ'Ø�4õ  +¨8Ñ4Ô4Ð4ˆOÐAÝ!5°h¸yÔ6IÑ!JÔ!JÐJÐØðGõ  ¥¤	¡¤Ñ,Ô,ˆMØ 1°MÑ AÐå! ! _Ð7HÑ%HÑIÔIˆH�U‰Oð ',ˆÔ#Øˆr   )	rA   rB   rC   rD   r   rE   r#   rY   rF   rG   s   @r   rI   rI   ‰   sl   ø€ € € € € ðð ð;ð ;ð ;ð ;ð ;ð
 ð(ð (ñ „Xð(ð%ð %ð %ð %ð %ð %ð %r   rI   c                   ó$   ‡ — e Zd ZdZdˆ fd„	Zˆ xZS )ÚCacheMiddlewarezÌ
    Cache middleware that provides basic behavior for many simple sites.

    Also used as the hook point for the cache decorator, which is generated
    using the decorator-from-middleware utility.
    Nc                 ó  •— t          ¦   «                              |¦  «         	 |d         }|€d}|| _        n# t          $ r Y nw xY w	 |d         }|€t          }|| _        n# t          $ r Y nw xY w|�|| _        || _        d S )Nr   Ú r   )r   r   r   ÚKeyErrorr   r   r   r   )r   r   r   r   Úkwargsr   r   r   s          €r   r   zCacheMiddleware.__init__Ë   sÁ   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&ð	Ø Ô-ˆJØÐ!Ø�
Ø(ˆDŒOˆOøÝð 	ð 	ð 	ØˆDð	øøøð	Ø  Ô/ˆKØÐ"Ý1�Ø*ˆDÔÐøÝð 	ð 	ð 	ØˆDð	øøøð Ð$Ø!.ˆDÔØ(ˆÔÐÐs!   ¤8 ¸
AÁAÁ	A" Á"
A/Á.A/)NN)rA   rB   rC   rD   r   rF   rG   s   @r   r[   r[   Ã   sG   ø€ € € € € ðð ð)ð )ð )ð )ð )ð )ð )ð )ð )ð )r   r[   )rD   rS   Údjango.confr   Údjango.core.cacher   r   Údjango.utils.cacher   r   r   r	   r
   Údjango.utils.deprecationr   Údjango.utils.httpr   r   rI   r[   r/   r   r   ú<module>re      sG  ðð+ð +ðZ €€€à  Ð  Ð  Ð  Ð  Ð  Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 5Ð 4Ð 4Ð 4Ð 4Ð 4Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ðIð Ið Ið Ið I˜Oñ Iô Ið IðX7ð 7ð 7ð 7ð 7˜ñ 7ô 7ð 7ðt )ð  )ð  )ð  )ð  )Ð+Ð-Eñ  )ô  )ð  )ð  )ð  )r   