Cache scope
Cache scope is another valuable component provided by MuleSoft that needs to be configured inside a Mule flow to store and reuse data that is regularly referred to. This will enhance the general overall performance of the software by decreasing the number of times operations are executed.
The following figure illustrates how caching works in a Mule flow.
Figure 18.3: Caching versus no caching
In Figure 18.3, we have one Mule flow without caching and one with caching. The Mule flow without caching will always connect to the database to retrieve the data for every request, whereas the Mule flow with caching will only connect to the database once during the first request and retrieve the data, which it will store in the cache and respond to the client. Any subsequent requests will receive a copy of the data from the cache instead of connecting the database again and again.
Caching is good for static data and data that changes infrequently...