I have written a post on my blog which directly answers this topic. My post covers in detail, how to install the code, how to use the code, and what the code does.
If you read my blog post, you will be able to easily, automatically clear caches on the WordPress action hook: save_post, from the WordPress plugin: W3 Total Cache.
Automatically clear all caches with W3 Total Cache
You have the following options for which caches to clear upon the WordPress action hook save_post:
Calls the W3TC function: w3tc_dbcache_flush();
Clears the DB caches completely. Note: Doesn’t clear MySQL Query Cache, just WP based DB caches.
Calls the W3TC function: w3tc_minify_flush();
Clears the minified content caches completely.
Calls the W3TC function: w3tc_objectcache_flush();
Clears the object caches completely.
Calls the W3TC function: w3tc_pgcache_flush();
Clears the Page Cache completely.
Calls each of the W3TC functions in one instance.
Attempts to clear all W3TC caches completely.