diff --git a/HtmlcachePlugin.php b/HtmlcachePlugin.php
index 2914cad..dc30ae7 100644
--- a/HtmlcachePlugin.php
+++ b/HtmlcachePlugin.php
@@ -237,4 +237,16 @@ public function registerCachePaths()
craft()->htmlcache_htmlcache->clearCacheFiles() => Craft::t('Htmlcache cached pages')
);
}
+
+ /**
+ * Adds routes to allow external webhook to clear cache
+ *
+ * @return array
+ */
+ public function registerSiteRoutes()
+ {
+ return array(
+ 'htmlcache/clearCache' => array('action' => 'htmlcache/webhook/clearCache'),
+ );
+ }
}
diff --git a/controllers/Htmlcache_WebhookController.php b/controllers/Htmlcache_WebhookController.php
new file mode 100644
index 0000000..4b20b8d
--- /dev/null
+++ b/controllers/Htmlcache_WebhookController.php
@@ -0,0 +1,12 @@
+htmlcache_htmlcache->clearCacheFiles();
+ }
+}
\ No newline at end of file
diff --git a/services/Htmlcache_HtmlcacheService.php b/services/Htmlcache_HtmlcacheService.php
index ad34407..aa64579 100644
--- a/services/Htmlcache_HtmlcacheService.php
+++ b/services/Htmlcache_HtmlcacheService.php
@@ -48,7 +48,10 @@ public function canCreateCacheFile()
if (craft()->request->isCpRequest()) {
return false;
}
-
+ // Skip if it's a webhook to clear cache
+ if (craft()->request->path == 'htmlcache/clearCache') {
+ return false;
+ }
// Skip if it's an action Request
if (craft()->request->isActionRequest()) {
return false;