  We consider the online caching problem for a cache of limited size. In a
time-slotted system, a user requests one file from a large catalog in each
slot. If the requested file is cached, the policy receives a unit reward and
zero rewards otherwise. We show that a Follow the Perturbed Leader (FTPL)-based
anytime caching policy is simultaneously regret-optimal for both adversarial
and i.i.d. stochastic arrivals. Further, in the setting where there is a cost
associated with switching the cached contents, we propose a variant of FTPL
that is order-optimal with respect to time for both adversarial and stochastic
arrivals and has a significantly better performance compared to FTPL with
respect to the switching cost for stochastic arrivals. We also show that these
results can be generalized to the setting where there are constraints on the
frequency with which cache contents can be changed. Finally, we validate the
results obtained on various synthetic as well as real-world traces.
