PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  ]c@sdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZddlmZddlmZmZmZdd lmZmZmZmZdd lmZdd lmZejd Zej d Z!dZ"dZ#dZ$dZ%ddZ'ddddZ(dZ)dZ*dZ+dZ,ddZ-dZ.dZ/dZ0dZ1dZ2dZ3dddd Z4dddd!Z5d"Z6dS(#u This module contains helper functions for controlling caching. It does so by managing the "Vary" header of responses. It includes functions to patch the header of response objects directly and decorators that change functions to do that header-patching themselves. For information on the Vary header, see: https://tools.ietf.org/html/rfc7231#section-7.1.4 Essentially, the "Vary" HTTP header defines which headers a cache should take into account when building its cache key. Requests with the same path but different header content for headers named in "Vary" need to get different cache keys to prevent delivery of wrong content. An example: i18n middleware would need to distinguish caches by the "Accept-language" header. i(tunicode_literalsN(tsettings(tcaches(t HttpResponsetHttpResponseNotModified(tRemovedInDjango21Warning(t force_bytest force_textt iri_to_uri(t http_datet parse_etagstparse_http_date_safet quote_etag(tget_current_timezone_name(t get_languageu\s*,\s*udjango.requestc s?dd|jdrStj|d}tfd|D}ni}d|krd|krtt|d|d|dsu Cache-Controlc3s|]}|VqdS(N((t.0tel(R(s6/usr/lib/python2.7/site-packages/django/utils/cache.pys Fsumax-ageumax_ageuprivateupublicu_u-u, c3s|]}|VqdS(N((RR(R(s6/usr/lib/python2.7/site-packages/django/utils/cache.pys XsN( tgett cc_delim_reRtdicttmintinttitemstreplacetjoin(tresponsetkwargstcctktv((RRs6/usr/lib/python2.7/site-packages/django/utils/cache.pytpatch_cache_control+s  $  %cCsu|jdsdStdtj|dD}d|krqyt|dSWqqttfk rmqqXndS(u Returns the max-age from the response Cache-Control header as an integer (or ``None`` if it wasn't found or wasn't an integer. u Cache-ControlNcss|]}t|VqdS(N(t _to_tuple(RR((s6/usr/lib/python2.7/site-packages/django/utils/cache.pys csumax-age(t has_headerRRRRt ValueErrort TypeError(R!R#((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyt get_max_age\s# cCs2|js.ttj|jj|d|s tS|dgkrtS|jdr0tS||kSdS(uM Test the If-Match comparison as defined in section 3.1 of RFC 7232. u*uW/N(tFalseRt startswith(t target_etagtetags((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyR?scCs|o||kS(u\ Test the If-Unmodified-Since comparison as defined in section 3.4 of RFC 7232. ((RERG((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyR@scCsJ|s tS|dgkrtS|jd}d|D}||kSdS(uR Test the If-None-Match comparison as defined in section 3.2 of RFC 7232. u*uW/css|]}|jdVqdS(uW/N(tstrip(RRD((s6/usr/lib/python2.7/site-packages/django/utils/cache.pys sN(RRKRO(RMRN((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyRAscCs| p||kS(uV Test the If-Modified-Since comparison as defined in section 3.3 of RFC 7232. ((RERI((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyRCscCs|dkrtj}n|dkr-d}ntjr|jd rtjdtt|drt |j r|j t qt |}n|jdst tj||d$su, N(R(RRtsetRR (R!t newheaderst vary_headerstexisting_headerst newheadertadditional_headers((s6/usr/lib/python2.7/site-packages/django/utils/cache.pytpatch_vary_headerss  cCsL|jdstStj|d}td|D}|j|kS(uS Checks to see if the response has a given header name in its Vary header. uVarycss|]}|jVqdS(N(R(RR;((s6/usr/lib/python2.7/site-packages/django/utils/cache.pys 1s(R(RKRRRaR(R!t header_queryRcRd((s6/usr/lib/python2.7/site-packages/django/utils/cache.pythas_vary_header*s cCstjstjr2|dt|dt7}ntjrttdd}|d|jddj dj dd7}n|S(uDIf necessary, adds the current locale or time zone to the cache key.u.%su LANGUAGE_CODEterrorsuignoreuasciiu u_( RtUSE_I18NtUSE_L10NtgetattrRtUSE_TZRR tencodetdecodeR(R7t cache_keyttz_name((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyt_i18n_cache_key_suffix5s   2c Cstj}xB|D]:}|jj|}|dk r|jt|qqWtjtt|j}d|||j |j f}t ||S(u>Returns a cache key from the headers given in the header list.u-views.decorators.cache.cache_page.%s.%s.%s.%sN( R-R.R>RRQtupdateRRtbuild_absolute_uriR0Rs( R7RBt headerlistt key_prefixtctxR;tvalueturlRq((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyt_generate_cache_keyFs   !cCsDtjtt|j}d||jf}t||S(u)Returns a cache key for the header cache.u)views.decorators.cache.cache_header.%s.%s(R-R.RRRuR0Rs(RwR7RzRq((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyt_generate_cache_header_keySs!uGETcCsy|dkrtj}nt||}|dkrCttj}n|j|}|dk rqt||||SdSdS(uf Returns a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against. If there is no headerlist stored, the page needs to be rebuilt, so this function returns None. N(RQRtCACHE_MIDDLEWARE_KEY_PREFIXR|RtCACHE_MIDDLEWARE_ALIASRR{(R7RwRBtcacheRqRv((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyt get_cache_key[s    c CsA|dkrtj}n|dkr0tj}nt||}|dkr[ttj}n|jdrtjpytj }g}x\t j |dD]G}|j j dd}|dkr|rqn|jd|qW|j|j|||t||j||S|j|g|t||jg|SdS(u Learns what headers to take into account for some request URL from the response object. It stores those headers in a global URL registry so that later access to that URL will know what headers to take into account without building the response object itself. The headers are named in the Vary header of the response, but we want to prevent response generation. The list of headers to use for cache key generation is stored in the same cache as the pages themselves. If the cache ages some data out of the cache, this just means that we have to build the response once to get at the Vary header and so at the list of headers to use for the cache key. uVaryu-u_uACCEPT_LANGUAGEuHTTP_N(RQRR}RRR|RR~R(RkRlRRtupperRtappendtsortRaR{RB( R7R!R[RwRRqtis_accept_language_redundantRvR;((s6/usr/lib/python2.7/site-packages/django/utils/cache.pytlearn_cache_keyqs(      cCsP|jdd}t|dkr<|dj|dfS|djtfS(Nu=iii(RRRR(RR((s6/usr/lib/python2.7/site-packages/django/utils/cache.pyR's(7t__doc__t __future__RR-tloggingtreRZRTt django.confRtdjango.core.cacheRt django.httpRRtdjango.utils.deprecationRtdjango.utils.encodingRRRtdjango.utils.httpR R R R tdjango.utils.timezoneR tdjango.utils.translationRtcompileRt getLoggerR4R&R+R1R8RQR<RJR?R@RARCR\R`RgRiRsR{R|RRR'(((s6/usr/lib/python2.7/site-packages/django/utils/cache.pytsH     " 1   *         *