Emerging optical communication technologies support the dynamic reconfiguration of datacenter network topologies depending on the traffic they serve. However, to reap the benefits of such demand-aware networks, a control logic is required which allows to quickly learn and adapt to traffic patterns. This paper presents CacheNet, a novel approach to efficiently control demand-aware networks. CacheNet leverages temporal and spatial locality in the traffic by managing the reconfigurable links of the optical switches as a links-cache. Network traffic, in turn, can be served either by a link from the link-cache component or by a demand-oblivious topology component. We study several classic caching algorithms and provide an analytical model which captures their performance benefits compared to an all demand-oblivious topology. Our analytical results show that based on the hit ratios and the links-cache size, our hybrid design can outperform designs that are based only on demand-oblivious topology.