adhocracy_core.caching package¶
Adapter and helper functions to set the http response caching headers.
-
set_cache_header(view: <built-in function callable>)[source]¶ Decorator for view to set http cache headers of the response.
-
register_cache_strategy(strategy_adapter: <InterfaceClass adhocracy_core.interfaces.IHTTPCacheStrategy>, iresource: <InterfaceClass zope.interface.interfaces.IInterface>, registry: pyramid.registry.Registry, view_or_method: str)[source]¶ Register a cache strategy for a specific context interface and view.
-
class
HTTPCacheStrategyBaseAdapter(context, request)[source]¶ Bases:
objectBasic cache strategy adapter a to set http cache headers.
You can register a cache strategy for a specific context and view with
adhocracy_core.caching.register_http_cache_strategy_adapter().For more information about caching headers read: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Initialize self.
-
browser_max_age= 0¶ Time (in seconds) to cache the response in the browser or caching proxy. Adds a “Cache-Control: max-age=<value>” header.
-
proxy_max_age= 0¶ Time (in seconds) to cache the response in the caching proxy. Adds a “Cache-Control: s-maxage=<value>” header to the response.
-
last_modified= False¶ Adds a “Last-Modified” header to the response and turns on “304 Not Modified” responses for “If-Modified-Since” conditional requests.
Tuple of etag functions (accepting context and request, return str) to build the Etag header. Turns on “304 Not Modified” responses for “If-None-Match” conditional requests.
-
vary= ()¶ Tuple of names of HTTP headers in the request that must match for a caching proxy to return a cached response.
-
context= None¶ The view context.
-
request= None¶ The request to set the cache headers.
-
check_conditional_request()[source]¶ Check if conditional_request and raise 304 Error if needed.
- raise pyramid.httpexceptions.HTTPNotModified:
- if conditional request and context is not modified.
-
-
etag_backrefs(context: <InterfaceClass adhocracy_core.interfaces.IResource>, request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return changed backrefs counter value.
-
etag_descendants(context: <InterfaceClass adhocracy_core.interfaces.IResource>, request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return changed descendants counter value.
-
etag_modified(context: <InterfaceClass adhocracy_core.interfaces.IResource>, request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return modification date.
-
etag_userid(context: <InterfaceClass adhocracy_core.interfaces.IResource>, request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return userid.
-
etag_blocked(context: <InterfaceClass adhocracy_core.interfaces.IResource>, request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return resource blocked status.
-
class
HTTPCacheStrategyWeakAdapter(context, request)[source]¶ Bases:
adhocracy_core.caching.HTTPCacheStrategyBaseAdapterWeak strategy adapter to set http cache header.
mode without-proxy-cache: browser cache 0 and force revalidate
- mode with-proxy-cache: browser cache 0, proxy cache forever but force
- revalidate
Initialize self.
-
browser_max_age= 0¶
-
proxy_max_age= 31104000¶
-
vary= ('Accept-Encoding', 'X-User-Path', 'X-User-Token')¶
-
class
HTTPCacheStrategyStrongAdapter(context, request)[source]¶ Bases:
adhocracy_core.caching.HTTPCacheStrategyBaseAdapterStrong strategy adapter to set http cache header.
mode without-proxy-cache: browser cache forever
- mode with-proxy-cache: browser cache forever, proxy cache forever but force
- revalidate
Initialize self.
-
browser_max_age= 31104000¶
-
proxy_max_age= 31104000¶
-
vary= ('Accept-Encoding', 'X-User-Path', 'X-User-Token')¶