cubicweb varnish helper
Project description
Summary
This cubes enables a purge mechanism for a cubicweb website that is sitting behind a varnish cache.
Internals
The purge mechanism consists of sending purge commands to the administration backend of varnish (by default localhost:6082). Generally it is recommended to protect this management port with a secret file which can be configured in this cube. Multiple backends can be controlled in this manner in a distributed setup.
Out of the box, this cube will not purge any URLs. The logic of which pages should be “purged” has to be implemented in content cubes.
To configure which urls to purge, you have to implement an IVarnishAdapter, for example
.. sourcecode:: python
from cubes.varnish.entities import IVarnishAdapter
- class BlogEntryVarnishAdapter(IVarnishAdapter):
__select__ = is_instance(‘BlogEntry’)
- def urls_to_purge(self):
- return (‘/’, #frontpage
self.entity.absolute_url(), #URL of blog post ‘/BlogEntry’ # list of blog entries)
Debugging : cubicweb-varnish will not crash when it cannot connect to the administrative port, it will silently log an error in the log.
Docker & Kubernetes
When deploying on docker or kubernetes, you can configure this with :
CW_VARNISHCLI_HOSTS=fqdn:6082,IP:PORT (csv with host:port)
CW_VARNISH_SECRETS=/etc/varnish_shared_secret_token (filename with token in it)
Dependencies
or apt-get install varnish (for debian derived distributions)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cubicweb_varnish-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20022b33639a9ac960aa02cbebb6fa1cfce8191860d3f9c3cb6930950a75bf94 |
|
MD5 | 3cf0abc7ea5b7e47286763ad48d9917c |
|
BLAKE2b-256 | 53715a5c514bcbb193342c15b7376aa716575e1acdd94a0e7cb9ec8cb3fc8bb1 |