DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Every Cache Miss Is a Tiny Tax on Your Performance
  • KV Cache Implementation Inside vLLM
  • The Bill You Didn't See Coming
  • Fine-Tuning of Spring Cache

Trending

  • Conversational Risk Accumulation: Stateful Guardrails Beyond Single-Turn LLM Checks
  • Grok AI API Tutorial: Chat, Image, Video, Tool Calling, and Web Search
  • Optimizing Arm-Based Build Servers With AmpereOne CPUs
  • I Reverse-Engineered 50 API Breaches. The Same Five Mistakes Keep Appearing.
  1. DZone
  2. Data Engineering
  3. Data
  4. Mule 4 Custom HTTP Radis Cache Policy

Mule 4 Custom HTTP Radis Cache Policy

The HTTP Custom Caching policy enables you to store HTTP responses from an API implementation or an API proxy for reuse. Let's discuss how to optimize this.

By 
Amit Ghorpade user avatar
Amit Ghorpade
·
May. 27, 21 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
12.0K Views

Join the DZone community and get the full member experience.

Join For Free

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?

  1. This means your runtime application needs to be deployed on cloudhub; runtime applications deployed on a customer-hosted runtime can’t use this in the built-in policy.
  2. It works with the standard configuration; if you need a custom configuration or expression to be used to pick up the key, then it is not possible with the out-of-the-box policy.

In this custom cache policy, the cache is backed by Redis storage which is an open-source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. In this example, we are using an Upstash service provider for Redis, as they provide on cloud Redis and only take 5 minutes to get a new Redis instance (via the trial version).

This custom cache policy flow is shown below:

Mule 4 Custom Cache Policy

Create a trial Redis server for us on Upstash. It takes 5 minutes to get a Redis database and can do testing using Redis-CLI.

Additional Resources

  • Getting started
  • Code repo 
  • How to develop a Mule 4 custom policy
Cache (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Every Cache Miss Is a Tiny Tax on Your Performance
  • KV Cache Implementation Inside vLLM
  • The Bill You Didn't See Coming
  • Fine-Tuning of Spring Cache

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook