When does Craft change or delete template caches?
Craft can delete caches in a few different ways:


When somebody manually clears the cache via Settings-&gt;Clear Caches
When Elements within {% cache %} tag are saved or deleted
When a new Element is created


Regarding #2 and #3, when Craft can identify which Elements you are caching, it stores them in the craft_templatecacheelements table.  If you save or delete an Element that matches one of the Element IDs that Craft has stored, Craft will clear the related template caches immediately.  In the case where you are creating a new Element, it takes Craft a little bit longer to determine if that Element could be part of a related cached query and once Craft determines that is the case, will clear the cache.

Craft knows which Element IDs exist if your queries are taking place between the {% cache %} tags.

If you'd like to explore a bit more, a few places to explore would be the craft/services/TemplateCacheService.php and craft/app/etc/templating/BaseTemplate.php.