Skip to main content

Proxy Caching Plugin

Updated Feb 26, 2023 ·

Overview

The Proxy Caching plugin improves performance by caching responses for frequently accessed resources.

  • Reduces backend load by serving cached responses.
  • Configurable cache rules based on request/response criteria.

Lab Environment

This lab tests a Kong API Gateway deployment using a FastAPI endpoint. To simplify, both the containerized Kong API Gateway and the FastAPI endpoint are installed locally on a Windows 10 machine. A Docker Compose file is used to deploy Kong, along with other applications like Prometheus, Zipkin, the ELK Stack, and more.

info

Make sure that you have installed Docker Desktop.

Simply installing Docker in WSL2 without Docker Desktop may introduce some issue when configuring the communication between the containerized Kong API Gateway and the FastAPI application that is installed on the local host.

Pre-requisites

Enable Proxy Caching Plugin

info

Make sure you have created the gateway service, routes, and the consumer/

To enable the plugin, go to Kong Manager > Plugins > New Plugin > Traffic Control > Select Proxy Caching.

Set it to Scoped and specify the service, route, and consumer that you want to implement the caching.

Also set the following configurations. Click Save.

FieldValue
Strategymemory
Cache Ttl300

Back in the Plugins page, temporarily disable the plugin first.

Test the plugin via Postman

Setup Postman

To setup Postman, please see Testing with Postman

Open Postman and create a new request. Rename it to FastAPI via Kong - Caching. Enter the URL below and click send.

http://localhost:8000/kong/healthy 

Go back to the Kong Manager UI > Plugins, then enable the Proxy Caching plugin.

Retry sending the request in Postman. There should now be a decrease in the response time.