<p>You'd need to write a <a href="https://pluginfactory.io/" rel="nofollow">super-simple plugin</a> that exposes a controller's action URL your deploy hook could hit.  That action would basically just mimic what the <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php" rel="nofollow">ClearCachesTool</a> does for clearing the various caches in Craft.</p>

<p>E.g. <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L123" rel="nofollow">Template caches</a>, <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L128" rel="nofollow">Asset Transform Index caches</a>, <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L133" rel="nofollow">Asset Index caches</a>, <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L110" rel="nofollow">general data caches</a>, etc.</p>

CC BY-SA 3.0
2016-08-19T17:16:38.837Z
2016-08-19T17:16:38.837Z
Brad Bell
<p>Does Craft have a built-in Controller/action for clearing the cache?
We have auto-deployment set to a server and would be useful to set up a POST-receive hook to force the cache to clear when deployments are made.</p>

CC BY-SA 3.0
2016-08-18T17:25:59.273Z
Which caches are you wanting to clear? Template caches? General data cache (`craft->cache`)? Asset caches? All of the above?
Brad Bell
CC BY-SA 3.0
2016-08-19T14:57:03.133Z
Yes, template caches primarily although asset might be useful in case assets are being pushed up (thought we generally tend to keep these out of our repos)
Cole Henley
<plugin-development><cache><controller>
Cache controller/action
# Cache controller/action

(Asked by: username_0 on 2016-08-18)

Does Craft have a built-in Controller/action for clearing the cache?
We have auto-deployment set to a server and would be useful to set up a POST-receive hook to force the cache to clear when deployments are made.

**Tags:** plugin-development, cache, controller
> **Comments:**
> **username_1**: Which caches are you wanting to clear? Template caches? General data cache (`craft->cache`)? Asset caches? All of the above?  
> **username_0**: Yes, template caches primarily although asset might be useful in case assets are being pushed up (thought we generally tend to keep these out of our repos)  

---

## 1 answers

### Answer by username_1 on 2016-08-19. Score: 2 | Accepted answer

You'd need to write a [super-simple plugin](https://pluginfactory.io/) that exposes a controller's action URL your deploy hook could hit. That action would basically just mimic what the [ClearCachesTool](https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php) does for clearing the various caches in Craft.

E.g. [Template caches](https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L123), [Asset Transform Index caches](https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L128), [Asset Index caches](https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L133), [general data caches](https://github.com/pixelandtonic/Craft-Release/blob/master/app/tools/ClearCachesTool.php#L110), etc.


---

