Azure / Azure/api-management-self-hosted-gateway

Cache Lookup `vary-by-query-parameter` not working

Open
#211 6 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Mustache
Stars
90
Forks
39
Avg merge
12h 4m
Merged PRs (30d)
4

Description

### Report

Cache Lookup policy should by default cache separately by all query parameters as stated in the [documentation at `vary-by-query-parameter`](https://learn.microsoft.com/en-us/azure/api-management/cache-lookup-policy#elements). Even when specifying the caching with `vary-by-query-parameter` element the caching still doesn't respect the caching. I would expect the query would be reflected in the cache key, which is not e.g. `3_apimtestwe.azure-api.net.23_static-api_static-api-uat;rev=1.38718_GetTenantApplicationsFooter.37979_8_https_graphql-we-uat.services.ori_443_/tenants/ee/applications/footer`

### Expected Behavior

Cache would take into account the query parameters.

### Actual Behavior

`CacheLookup` with `vary-by-query-parameter` should store backend request separately based on the query parameters defined.

### Steps to Reproduce the Problem

1. Define `/tenants/{tenant}/applications/footer?lang={lang}` endpoint
2. Define policy with `` with `lang` element
3. Call the endpoint with different `lang` values
4. The cache should contain multiple entries differing based on the query parameter

### Logs from self-hosted gateway

None

### Self-hosted Gateway Version

2.2.0

### Deployment

Self-Managed (YAML/Helm)

### Platform

Microsoft Azure

### Kubernetes Version

1.25

### Anything else?

The issue is reproducible on Managed API Management as well.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Cache Lookup policy scenario from the issue on the self-hosted gateway deployment, using the documented vary-by-query-parameter element and differing lang values. Trace the cache behavior for the /tenants/{tenant}/applications/footer endpoint and compare the resulting entries or keys. Done means requests with different defined query parameters produce separate cache entries on both self-hosted and managed API Management.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, helm, kubernetes
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.