This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

WSO2 ESB provides a caching tool that is used to cache responses for requests that are identical, thereby enhancing the response time for subsequent requests. When caching is enabled, subsequent requests with same hash value as the previous request whose response was cached, will be served with the same cached response. Caching can be enabled at three levels:

  • Service level - If caching is engaged at service level, all the responses that are generated by all the operations of that particular service will be cached.
  • Global level - Global level engagement of caching will apply caching for all the messages coming into a hosted server instance. All the responses from all the services will be cached.
  • Operation level - If engaged at operation level, only those responses from that particular operation of a given service will be cached.

Adding Response Caching to a Service

Follow the instructions below to add response caching to the service.

1. Sign in. Enter your user name and password to log on to the ESB Management Console.

2. Click on Main in the left menu to access the Manage menu.

3. In the Manage menu, click List under Web Services.

4. The Deployed Services page appears.

5. Click on the service, for which you want to activate response caching. The Service Dashboard page appears.

6. Click Response Caching in the Quality of Service Configuration panel.

7. The Caching Configuration for Service page appears.

8. In the Enable Caching list, click Yes.

9. The last saved configuration or the default configuration (if it is the first time) for caching will be displayed.

Fields in Wizard:

  • Hash Generator - Specifies the fully qualified class name of the hash value generator. This class implements the org.wso2.caching.digest.DigestGenerator interface. It is responsible for generating a "Hash" value for each request message, so that a matching response message can be located from the cache. The default is org.wso2.caching.digest.DOMHASHGenerator. You can implement your own hash generator class using the  org.wso2.caching.digest.DigestGenerator interface, and use it with WSO2 ESB. However, the default hash generator should be good enough for general use.
  • Timeout - Shows the time period, in milliseconds, that a cached response is kept in memory. The counting starts from the time the first request is received. Any request, received after the counter has started and is within the Timeout period, is served with the response cached upon receiving the first request. Once the Timeout expires, the cache will be updated with the response generated for the first request that was received after the expiry.
  • Maximum Cache Size - Holds the maximum number of response messages that will be cached. If the maximum number of responses are already cached and none of the cached responses' Timeouts have expired, then future responses are not cached until this memory is free enough to accommodate caching a new response.
  • Maximum Message Size - Shows the response message that is cached. Response messages larger than this (in size) are not cached. Caching is an expensive operation for larger messages, especially given the amount of memory required. Therefore this value should be set considering the performance and resource trade-offs.


  • It is advised that you consider the dynamic nature of your services before you enable caching globally. For example, an operation that is supposed to generate random numbers would not benefit from caching previous responses, because it is supposed to generate a unique response for each invocation.
  • WSO2 ESB currently supports configuring caching at service level and global level. If you want to engage the caching capability at operational level, you have to edit the configuration file of the service manually and engage it at operation level.

10. Click Finish. Caching will be engaged for that particular service.

Functions of Buttons:

  • Finish - Click "Finish" to submit the current data. When finished, your throttle configuration will be applied and the page will be redirected to the previous page.
  • Reset - Click "Reset" to load the last submitted configuration.
  • Default - Click "Default" to load the default throttle configuration. If you want to submit those data, you have to click "Finish."
  • Clear - Click "Clear" to clear all the text boxes in the user interface.
  • Cancel - Click "Cancel" to go to the "Service Dashboard" page.



  • No labels