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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Why GPUs Run at 40% in LLM Inference and How To Fix It
  • Prompt Caching for Multi-Turn Coding Agents: Why Append-Only Transcripts Cut Your Token Bill
  • Prompt Caching for LLMs, Part 3: Model-Side Caching and Production Rollout
  • Prompt Caching for LLMs, Part 2: Semantic Caching in Production

Trending

  • Prompt Caching for Multi-Turn Coding Agents: Why Append-Only Transcripts Cut Your Token Bill
  • Building DynamoDB Streams Compatibility on Apache Phoenix
  • How Has AI Impacted Code Obfuscation?
  • Idempotency Under Concurrency: Why Your Application Check Isn't the Last Line of Defense

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
May. 27, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
12.1K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Why GPUs Run at 40% in LLM Inference and How To Fix It
  • Prompt Caching for Multi-Turn Coding Agents: Why Append-Only Transcripts Cut Your Token Bill
  • Prompt Caching for LLMs, Part 3: Model-Side Caching and Production Rollout
  • Prompt Caching for LLMs, Part 2: Semantic Caching in Production

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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