This makes it possible to have frontends react instantly to changes,
while maintaining high cacheability.
+Any model can also define a tuple or function called *purge_xkeys*.
+This work exactly the same way except it purges based on xkey instead
+of URL, which is usually the better choice.
+
Finally, there is a form on the admin web interface that lets the
administrator manually purge pages from the caches. This may be
necessary if changes have been made to static pages and/or site
yield '/$'
yield '/support/versioning'
yield '/support/security'
- yield '/docs/$'
- yield '/docs/manuals'
yield '/about/featurematrix/$'
yield '/versions.rss'
yield '/versions.json'
+ def purge_xkeys(self):
+ yield 'pgdocs_all'
+
class Country(models.Model):
name = models.CharField(max_length=100, null=False, blank=False)
import difflib
from pgweb.util.middleware import get_current_user
-from pgweb.util.misc import varnish_purge
+from pgweb.util.misc import varnish_purge, varnish_purge_xkey
from pgweb.util.moderation import ModerationState
from pgweb.mailqueue.util import send_simple_mail
else:
purgelist = instance.purge_urls
list(map(varnish_purge, purgelist))
+ if hasattr(instance, 'purge_xkeys'):
+ if callable(instance.purge_xkeys):
+ purgelist = instance.purge_xkeys()
+ else:
+ purgelist = instance.purge_xkeys
+ list(map(varnish_purge_xkey, purgelist))
def register_basic_signal_handlers():
# Special handling of developer docs...
ver = "devel"
- curs.execute("SELECT varnish_purge('^/docs/' || %(v)s || '/')", {'v': ver})
+ curs.execute("SELECT varnish_purge_xkey('pgdocs_{}')".format(ver))
+ curs.execute("SELECT varnish_purge_xkey('pgdocs_all')")
if iscurrent:
- curs.execute("SELECT varnish_purge('^/docs/current/')")
+ curs.execute("SELECT varnish_purge_xkey('pgdocs_current')")
# ensure the changes are committed, and close the connection
connection.commit()