Search code examples
cachingterminologymemoization

What is the difference between Caching and Memoization?


I would like to know what the actual difference between caching and memoization is.
As I see it, both involve avoiding repeated function calls to get data by storing it.

What's the core difference between the two?


Solution

  • Memoization is a specific form of caching that involves caching the return value of a function based on its parameters.

    Caching is a more general term; for example, HTTP caching is caching but not memoization.

    Wikipedia says:

    Although related to caching, memoization refers to a specific case of this optimization, distinguishing it from forms of caching such as buffering or page replacement.