Computer cache - data removing
Cache lines are evicted :


When the OS requests it, it may occur for example in non cache-coherent systems when a peripheral does a DMA transfer (direct transfer from a peripheral to main memory), or if the CPU is shut down to save its state to RAM...
When all the ways of the cache are already used for the requested line.


In a write-through cache, new data can be directly loaded, overwriting previous contents. In a write-back cache, if the cache line was modified, it must be written back before loading new data.

There could be other exceptional cases, for example if a parity error is detected and new data must be loaded...
But, generally, caches are filled but never emptied.