o 3a@sXddlmZddlmZddlmZmZddlmZdddddZ d d Z d d Z dS) wraps)CacheMiddleware)add_never_cache_headerspatch_cache_control)#decorator_from_middleware_with_argsN)cache key_prefixcCstt|||dS)a9 Decorator for views that tries getting the page from the cache and populates the cache if the page isn't in the cache yet. The cache is keyed by the URL and some data from the headers. Additionally there is the key prefix that is used to distinguish different cache areas in a multi-site setup. You could use the get_current_site().domain, for example, as that is unique across a Django project. Additionally, all headers from the response's Vary header will be taken into account on caching -- just like the middleware does. ) page_timeout cache_aliasr )rr)timeoutrr r ?/usr/lib/python3/dist-packages/django/views/decorators/cache.py cache_pagesrc sfdd}|S)Ncstfdd}|S)Ncs*|g|Ri|}t|fi|SN)r)requestargskwresponse)kwargsviewfuncr r_cache_controlledszCcache_control.._cache_controller.._cache_controlledr)rrr)rr_cache_controllersz(cache_control.._cache_controllerr )rrr rr cache_controls rcstfdd}|S)zT Decorator that adds headers to a response so that it will never be cached. cs"|g|Ri|}t||Sr)r)rrrr view_funcr r_wrapped_view_func*sz'never_cache.._wrapped_view_funcr)rrr rr never_cache&sr) functoolsrdjango.middleware.cacherdjango.utils.cacherrdjango.utils.decoratorsrrrrr r r rs