Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions HtmlcachePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
}
}
12 changes: 12 additions & 0 deletions controllers/Htmlcache_WebhookController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Craft;

class Htmlcache_WebhookController extends BaseController
{
protected $allowAnonymous = true;

public function actionClearCache()
{
craft()->htmlcache_htmlcache->clearCacheFiles();
}
}
5 changes: 4 additions & 1 deletion services/Htmlcache_HtmlcacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down