Is it possible to clear caches and re-index assets programattically?
I guess it depends. So, behind the scenes, Craft can have different cache drivers. You might use the db or file cache, or something like Redis or Memcache.

Took a peek at ClearCachesTool, and it looks like it's doing the things you mentioned:

craft()-&gt;db-&gt;createCommand()-&gt;truncateTable('assettransformindex');
craft()-&gt;db-&gt;createCommand()-&gt;truncateTable('assetindexdata');


As well as deleting all the internal cache folders (runtime/cache, assets, compiled_templates, temp), including any plugin cache paths that have registered via registerCachePaths.

craft()-&gt;db-&gt;createCommand()-&gt;delete(static::$_templateCachesTable);


It also deletes the templates cache.

I guess what you're looking for are these:


CacheService->flush()
ClearCachesTool->performAction() (does most of the clearing)
craft()->templateCache->deleteAllCaches(); (called in ClearCachesTool - TemplateCacheService)


So yes, you can either bootstrap Craft and call a php file from the commandline, or add a plugin with an action that you GET/POST to after deployment.

The former, you can do with the included bootstrap.php file (as of 2.2)

$craft = require 'craft/app/bootstrap.php';