Ë
    ¹ûàg'!  ã                   ó¤   — 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y)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                   ó>   ‡ — 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                  | _	        y ©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     €úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/middleware/cache.pyr   zUpdateCacheMiddleware.__init__G   sA   ø€ Ü‰Ñ˜Ô&Ü%×>Ñ>ˆÔØ ˆÔÜ"×>Ñ>ˆŒÜ#×:Ñ:ˆÕó    c                 ó(   — t         | j                     S r   ©r   r   ©r   s    r   ÚcachezUpdateCacheMiddleware.cacheN   ó   € ä�d×&Ñ&Ñ'Ð'r   c                 ó6   — t        |d«      xr |j                  S )NÚ_cache_update_cache)Úhasattrr&   )r   ÚrequestÚresponses      r   Ú_should_update_cachez*UpdateCacheMiddleware._should_update_cacheR   s   € Ü�wÐ 5Ó6ÒV¸7×;VÑ;VÐVr   c                 óp  ‡ ‡‡— ‰ j                  ||«      s|S |j                  s|j                  dvr|S |j                  s|j                  rt        |d«      r|S d|j                  dd«      v r|S ‰ j                  Š‰€!t        |«      Š‰€‰ j                  Šn‰dk(  r|S t        |‰«       ‰r‰|j                  dk(  rzt        ||‰‰ j                  ‰ j                  ¬«      Št        |d	«      r-t        |j                   «      r|j#                  ˆˆ ˆfd
„«       |S ‰ j                  j%                  ‰|‰«       |S )zSet the cache, if needed.)éÈ   i0  ÚCookieÚprivatezCache-Control© r   r,   ©r#   Úrenderc                 ó>   •— ‰j                   j                  ‰| ‰«      S r   )r#   Úset)ÚrÚ	cache_keyr   Útimeouts    €€€r   ú<lambda>z8UpdateCacheMiddleware.process_response.<locals>.<lambda>~   s   ø€ ˜dŸj™jŸn™n¨Y¸¸7ÓC€ r   )r*   Ú	streamingÚstatus_codeÚCOOKIESÚcookiesr   Úgetr   r   r   r
   r	   r   r#   r'   Úcallabler1   Úadd_post_render_callbackr3   )r   r(   r)   r5   r6   s   `  @@r   Úprocess_responsez&UpdateCacheMiddleware.process_responseU   s)  ú€ à×(Ñ(¨°(Ô;àˆOà×Ò ×!5Ñ!5¸ZÑ!GØˆOð
 —’Ø× Ò Ü ¨(Ô3àˆOð ˜Ÿ™ _°bÓ9Ñ9ØˆOð ×#Ñ#ˆØˆ?ô " (Ó+ˆGØˆØ×,Ñ,‘Ø˜A’à�Ü˜x¨Ô1Ù�x×+Ñ+¨sÒ2Ü'Ø˜ 7¨D¯O©OÀ4Ç:Á:ôˆIô �x Ô*¬x¸¿¹Ô/HØ×1Ñ1ÝCôð
 ˆð —
‘
—‘˜y¨(°GÔ<Øˆr   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr#   r*   r?   Ú__classcell__©r   s   @r   r   r   =   s,   ø„ ñô;ð ñ(ó ð(òWö-r   r   c                   ó8   ‡ — 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                 óx   •— t         ‰| �  |«       t        j                  | _        t        j
                  | _        y r   )r   r   r   r   r   r   r   r   s     €r   r   z!FetchFromCacheMiddleware.__init__Ž   s+   ø€ Ü‰Ñ˜Ô&Ü"×>Ñ>ˆŒÜ#×:Ñ:ˆÕr   c                 ó(   — t         | j                     S r   r!   r"   s    r   r#   zFetchFromCacheMiddleware.cache“   r$   r   c                 ó&  — |j                   dvrd|_        yt        || j                  d| j                  ¬«      }|€d|_        y| j                  j                  |«      }|€M|j                   dk(  r>t        || j                  d| j                  ¬«      }| j                  j                  |«      }|€d|_        yt        |«      x}�Et        |d   «      x}	 �4t        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ÚHEADFNrL   r0   TrM   ÚExpiresr   ÚAge)Úmethodr&   r   r   r#   r<   r   r   ÚintÚtimeÚmax)r   r(   r5   r)   Úmax_age_secondsÚexpires_timestampÚnow_timestampÚremaining_secondss           r   Úprocess_requestz(FetchFromCacheMiddleware.process_request—   s  € ð
 �>‰> Ñ0Ø*/ˆGÔ'Øô " '¨4¯?©?¸EÈÏÉÔTˆ	ØÐØ*.ˆGÔ'ØØ—:‘:—>‘> )Ó,ˆàÐ §¡°&Ò 8Ü%Ø˜Ÿ™¨&¸¿
¹
ôˆIð —z‘z—~‘~ iÓ0ˆHàÐØ*.ˆGÔ'Øô  +¨8Ó4Ð4ˆOÐAÜ!5°h¸yÑ6IÓ!JÐJÐØðGô  ¤§	¡	£Ó,ˆMØ 1°MÑ AÐä! ! _Ð7HÑ%HÓIˆH�U‰Oð ',ˆÔ#Øˆr   )	r@   rA   rB   rC   r   rD   r#   rX   rE   rF   s   @r   rH   rH   …   s&   ø„ ñô;ð
 ñ(ó ð(ö%r   rH   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.
    c                 óÌ   •— t         ‰| �  |«       	 |d   }|€d}|| _        	 |d   }|€t        }|| _        |�|| _        || _        y # t        $ r Y Œ1w xY w# t        $ r Y Œ+w xY w)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ð	Ø  Ñ/ˆKØÐ"Ü1�Ø*ˆDÔð Ð$Ø!.ˆDÔØ(ˆÕøô ò 	Ùð	ûô ò 	Ùð	ús"   ’A £A Á	AÁAÁ	A#Á"A#)NN)r@   rA   rB   rC   r   rE   rF   s   @r   rZ   rZ   ¿   s   ø„ ñ÷)ñ )r   rZ   )rC   rR   Údjango.confr   Údjango.core.cacher   r   Údjango.utils.cacher   r   r   r	   r
   Údjango.utils.deprecationr   Údjango.utils.httpr   r   rH   rZ   r/   r   r   ú<module>rd      sT   ðñ+óZ å  ß 9÷õ õ 5Ý 2ôE˜Oô EôP7˜ô 7ôt )Ð+Ð-Eõ  )r   