{"id":18830238,"url":"https://github.com/gravitee-io/gravitee-policy-cache","last_synced_at":"2026-01-27T05:03:49.045Z","repository":{"id":5355623,"uuid":"52966874","full_name":"gravitee-io/gravitee-policy-cache","owner":"gravitee-io","description":"Gravitee Policy - Caching","archived":false,"fork":false,"pushed_at":"2026-01-19T06:44:37.000Z","size":230,"stargazers_count":1,"open_issues_count":2,"forks_count":6,"subscribers_count":23,"default_branch":"master","last_synced_at":"2026-01-19T15:03:44.525Z","etag":null,"topics":["security-scan"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gravitee-io.png","metadata":{"files":{"readme":"README.adoc","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-03-02T13:59:23.000Z","updated_at":"2026-01-19T06:44:41.000Z","dependencies_parsed_at":"2023-11-24T17:25:05.379Z","dependency_job_id":"7bd531e1-9f22-41b5-a3ce-41c9b98d591f","html_url":"https://github.com/gravitee-io/gravitee-policy-cache","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/gravitee-io/gravitee-policy-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitee-io%2Fgravitee-policy-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitee-io%2Fgravitee-policy-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitee-io%2Fgravitee-policy-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitee-io%2Fgravitee-policy-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gravitee-io","download_url":"https://codeload.github.com/gravitee-io/gravitee-policy-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitee-io%2Fgravitee-policy-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["security-scan"],"created_at":"2024-11-08T01:48:14.211Z","updated_at":"2026-01-27T05:03:49.040Z","avatar_url":"https://github.com/gravitee-io.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"= Cache policy\n\nifdef::env-github[]\nimage:https://img.shields.io/static/v1?label=Available%20at\u0026message=Gravitee.io\u0026color=1EC9D2[\"Gravitee.io\", link=\"https://download.gravitee.io/#graviteeio-apim/plugins/policies/gravitee-policy-cache/\"]\nimage:https://img.shields.io/badge/License-Apache%202.0-blue.svg[\"License\", link=\"https://github.com/gravitee-io/gravitee-policy-cache/blob/master/LICENSE.txt\"]\nimage:https://img.shields.io/badge/semantic--release-conventional%20commits-e10079?logo=semantic-release[\"Releases\", link=\"https://github.com/gravitee-io/gravitee-policy-cache/releases\"]\nimage:https://circleci.com/gh/gravitee-io/gravitee-policy-cache.svg?style=svg[\"CircleCI\", link=\"https://circleci.com/gh/gravitee-io/gravitee-policy-cache\"]\nendif::[]\n\n== Phase\n\n|===\n|onRequest |onResponse\n\n| X\n|\n\n|===\n\n== Description\n\nYou can use the `cache` policy to cache upstream responses (content, status and headers) to eliminate the need for subsequent calls to the back end.\n\nThis policy is based on a _cache resource_, which aligns the underlying cache system with the API lifecycle (stop / start).\n\nConsumers can bypass the cache by adding a `cache=BY_PASS` query parameter or by providing a `X-Gravitee-Cache=BY_PASS` HTTP header.\n\nNOTE: If no cache resource is defined for the policy, or it is not well configured, the API will not be deployed. The resource name is specified in the\npolicy configuration `cacheName`, as described below.\n\n== Compatibility with APIM\n\n|===\n| Plugin version | APIM version\n\n| 1.x            | 3.x\n| 2.x            | 4.0 to 4.9\n| 3.x            | 4.10 to latest\n|===\n\n== Configuration\n\nYou can configure the policy with the following options:\n\n|===\n|Property |Required |Description |Type |Default\n\n|cacheName|X|The cache resource used to store the element|string|\n|key||The key used to store the element (support EL)|string|\n|timeToLiveSeconds|X|Time to live of the element put in cache (Default to 10 minutes)|integer|600\n|methods|X|Select which method you want to cache|array of strings|[GET, OPTIONS, HEAD]\n|responseCondition||Add an extra condition (with Expression Language) based on the response to activate cache. For example use `{#upstreamResponse.status == 200}` to only cache 200 responses status. By default, all 2xx are cached.|string|\n|useResponseCacheHeaders||Time to live based on 'Cache-Control' and / or 'Expires' headers from backend response|boolean|false\n|scope|X|Cached response can be set for a single consumer (application) or for all applications.\u003cbr\u003e\u003cstrong\u003eWARNING:\u003c/strong\u003e Please be aware that by using an \\\"API\\\" scope, data will be shared between all consumers !|API / APPLICATION|APPLICATION\n\n|===\n\n== Examples\n\nThe key used to store elements in cache can use the Gravitee Expression Language to provide a dynamic value.\n\nTIP: To learn more about the Gravitee Expression Language, see the *API Publisher Guide*.\n\n=== Key based on the `productId` query parameter\n\n[source, json]\n----\n\"key\": \"{#request.params['productId']}\"\n----\n\n=== Key based on the `api-key` of the consumer\n\n[source, json]\n----\n\"key\": \"{#request.headers['X-Gravitee-Api-Key']}\"\n----\n\n=== Key based on an API's property and a query parameter\n\n[source, json]\n----\n\"key\": \"{#properties['siteID']}-{#request.params['productId']}\"\n----\n\n=== Configuration example\n\n[source, json]\n----\n\"cache\": {\n    \"cacheName\": \"policy-cache\",\n    \"key\": \"{#request.params['productId']}\",\n    \"timeToLiveSeconds\": 600,\n    \"useResponseCacheHeaders\": false,\n    \"scope\": \"APPLICATION\",\n    \"methods\": [\"POST\"],\n    \"responseCondition\": \"{#upstreamResponse.status == 201}\"\n}\n----\n\n\n=== Gateway configuration (gravitee.yml)\n\nWARNING: The `binary` serialization format is not compatible with the Redis cache resource.\n\n[source, yaml]\n----\n  policy:\n    cache:\n      serialization: text # default value or \"binary\" (not compatible with Redis)\n----\n\nThe `policy.cache.serialization` allow to configure the serialization format of the cache.\n\nThe default value is `text` but you can also use `binary` to use a binary serialization format (not compatible with Redis).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravitee-io%2Fgravitee-policy-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgravitee-io%2Fgravitee-policy-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravitee-io%2Fgravitee-policy-cache/lists"}