Special Price render

I’ve seen that Magento output special prices without using knockout or some ajax. Special price has time to display(from, to). How magento hide prices when time is expired? How it compatible with magento build-in cache and varnish? I have seen magento docs about private and public cache, but i can’t understand how it works with special prices.