def save(self, *args, **kwargs): # TODO: make main groups url an environment variable # and replace hardcoded /groups throughout site super(Group, self).save(*args, **kwargs) if self.slug: purge_url_from_cache('/groups/') purge_url_from_cache('/groups/' + self.slug + '/')
def purge(url=None): if url: purge_url_from_cache(url) return "flushed %s" % url else: config = settings.WAGTAILFRONTENDCACHE['akamai'] backend = AkamaiBackend(config) backend.purge_all() return "flushed entire site"
def invalidate_frontend_cache_for_site(sender, instance, **kwargs): # Purge site-specific score breakdown page purge_url_from_cache(reverse(instance.site)) # Purge the leaderboard purge_url_from_cache(reverse('sites:index')) # Purge the home page because it displays a subset of the leaderboard, as well as some summary statistics. purge_url_from_cache('/')
def purge_document_from_cache(instance, **kwargs): if not kwargs.get('created', False): base_url = get_base_url() purge_url_from_cache( base_url + reverse('wagtailapi_v1:documents:detail', args=(instance.id, )))
def purge_page_from_cache(instance, **kwargs): base_url = get_base_url() purge_url_from_cache( base_url + reverse('wagtailapi_v1:pages:detail', args=(instance.id, )))
def purge_document_from_cache(instance, **kwargs): if not kwargs.get('created', False): base_url = get_base_url() purge_url_from_cache(base_url + reverse('wagtailapi_v1:documents:detail', args=(instance.id, )))
def purge_page_from_cache(instance, **kwargs): base_url = get_base_url() purge_url_from_cache(base_url + reverse('wagtailapi_v1:pages:detail', args=(instance.id, )))
def purge_cache_on_all_sites(path): if settings.DEBUG: return for site in Site.objects.all(): purge_url_from_cache('%s%s' % (site.root_url.rstrip('/'), path))
def purge_image_from_cache(instance, **kwargs): if not kwargs.get("created", False): base_url = get_base_url() purge_url_from_cache(base_url + reverse("wagtailapi_v1:images:detail", args=(instance.id,)))
def handle(self, *args, **options): page_url = options['url'] purge_url_from_cache(page_url)