As described above, caches work on the assumption that data that is accessed once will usually be accessed soon again. This kind of behaviour is known as data locality. There are two kinds of locality that are sometimes distinguished:
Temporal locality means that the program reuses the same data that it recently used, and that therefore is likely to be in the cache.
Spatial locality means that the program uses data close to recently accessed locations. Since the processor loads a chunk of memory around an accessed location into the cache, locations close to recently accessed locations are also likely to be in the cache.
It is of course possible for a program exhibit both types of locality at the same time.
Good data locality is essential for good application performance. Applications with poor data locality reduce the effectiveness of the cache, causing long stall times waiting for memory accesses.