To answer the question in your title, it depends on what the caching protocol is. If it is write-back, the cache will only be flushed back to main memory when the cache controller has no choice but to put a new cache block in already occupied space. The block that previously occupied the space is removed and its value is written back to the main memory.
The other protocol is write-through. In that case, anytime the cache block is written on level n, the corresponding block on level (n+1) is updated. (It is similar in concept to filling our a form with carbon paper underneath; whatever you write on top is copied on the sheet below.) This is slower because it obviously involves more writing operations, but the values between caches are more consistent. In the write-back scheme, only the highest level cache would have the most up-to-date value for a particular memory block.
1I wonder what percentage of readers here have ever used carbon paper. :) – Barmar – 2015-01-30T18:41:12.060