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, control logic that quickly learns and adapts to traffic patterns is required. This paper presents CacheNet, a novel approach to efficiently control demand-aware networks. CacheNet consists of two components, a demand-aware links-cache, and a demand-oblivious topology. 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 links-cache component or by a demand-oblivious topology component. We study several classic caching algorithms like online LFU and LRU as our caching algorithms, as well as offline optimal caching as a benchmark, 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, when considering the average packet delay, our hybrid design outperforms a design that is based only on demand-oblivious topology. We also evaluate CacheNet empirically, using both synthetic and real-world traffic traces, confirming the potential of our approach to consider reconfigurable links as a network of links-cache.