Like Bhashkar said, that code should work in either a PHP-enabled template or put in a plugin and then put in a template. Then call the template to clear cache.
A more advanced way, and probably the proper way to do it, is to create a simple module, which can use an Action URL. Stephen Lewis wrote a blog post about what Actions are. Basically, an action maps a url like
http://domain.com/index.php?ACT=123 (where 123 is the action ID) to any method in your module. You can use it to trigger the cache clearing.
Say you add this method to your
public function clear_cache()
$this->EE->functions->clear_caching('all', '', TRUE);
Then in your
upd.my_addon.php file, inside the
install() method, you need to add the action. Something like this:
'class' => 'My_addon',
'method' => 'clear_cache'
My_addon is the name of the class in the
mod.my_addon.php file and
clear_cache refers to the method you want to execute.
You could even add a check in your own
clear_cache method for something like a secret key, so URL-hackers can't accidentally (or deliberately) trigger it.
Sounds like something one could learn in a certain workshop. ;)