In this paper we propose models for both temporal and spatial locality of reference in streams of requests am'ving at Web servers. W e show that simple models based on document popularity alone are insuficient for capturing either temporal or spatial locality. Instead, we rely on an equivalent, but numerical, representation of a reference stream: a stack distance trace. W e show that temporal locality can be characterized by the marginal distribution of the stack distance trace, and we propose models for typical distributions and compare their cache performance to our traces. W e also show that spatial Iocality an a reference stream can be characterized using the notion of self-similarity. Self-similarity describes longrange correlations an the dataset, which is a property that previous researchers have found hard t o incorporate into synthetic reference strings. W e show that stack distance strings appear to be stongly self-similar, and we provide measurements of the degree of self-similarity an our traces. Finally, we discuss methods for generating synthetic Web traces that exhibit the properties of temporal and spatial locality that we measured an our data.