Mule 4 Custom HTTP Radis Cache Policy

Introduction

The HTTP Custom Caching policy enables you to store HTTP responses from an API implementation or an API proxy for reuse. To optimize against computation-heavy processing, this policy avoids performing multiple calls to the backend when the response of a service does not change often. This policy uses a cache, which enables a faster service for data requests.

In Mule 4, Mulesoft already provides an HTTP cache policy, which is available out of the box with standard configuration and works very well with runtime object-store v2. If an existing out-of-the-box policy is available then why do we need a custom policy?

Working With Custom Policy in Mule 4

MuleSoft Custom Policies can be layered on top of the implementation of the APIs to provide the governance, security, and visibility required. While the out-of-the-box API management policies cover the majority of use cases, an organization may need to create a custom policy to meet specific business needs.

There is a lot of documentation that shows how to work with MuleSoft custom policies through API manager, however, developing the custom policy and debugging them locally has been always challenging. In this article, I will demonstrate how to develop and test Mule custom policy on your local standalone Mule runtime instances before uploading to the API manager or Exchange for live running APIs.