LDAP directories have recently proliferated with the growth of the Internet, and are being used in a wide variety of network-based
applications. In this paper, we propose the use of generalized queries, referred to as query templates, obtained by generalizing individual user queries, as the semantic basis for low overhead, high benefit LDAP directory caches
for handling declarative queries. We present efficient incremental algorithms that, given a sequence of user queries, maintain
a set of potentially beneficial candidate query templates, and select a sub-set of these candidates for admission into the
directory cache. A novel feature of our algorithms is their ability to deal with overlapping query templates. Finally, we
demonstrate the advantages of template caches over query caches, with an experimental study based on real data and a prototype
implementation of the LDAP directory cache.