{
  "schema_version": 2,
  "id": "commands/client-caching",
  "title": "CLIENT CACHING",
  "url": "https://redis.io/docs/latest/commands/client-caching/",
  "summary": "Instructs the server whether to track the keys in the next request.",
  "since": "6.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:21+01:00",
  "page_type": "content",
  "content_hash": "b9814f65215cc5bbad0ac7827648d611b6b4223a56aec5c59bc4295a8f5138dc",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command controls the tracking of the keys in the next command executed\nby the connection, when tracking is enabled in `OPTIN` or `OPTOUT` mode.\nPlease check the\n[client side caching documentation](https://redis.io/docs/latest/develop/clients/client-side-caching) for\nbackground information.\n\nWhen tracking is enabled in Redis, using the [`CLIENT TRACKING`](https://redis.io/docs/latest/commands/client-tracking) command, it is\npossible to specify the `OPTIN` or `OPTOUT` options, so that keys\nin read only commands are not automatically remembered by the server to\nbe invalidated later. When we are in `OPTIN` mode, we can enable the\ntracking of the keys in the next command by calling `CLIENT CACHING YES`\nimmediately before it. Similarly when we are in `OPTOUT` mode, and keys\nare normally tracked, we can avoid the keys in the next command to be\ntracked using `CLIENT CACHING NO`.\n\nBasically the command sets a state in the connection, that is valid only\nfor the next command execution, that will modify the behavior of client\ntracking."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>YES | NO</code></summary>\n\nWhether to cache keys for the next command (`YES`) or not (`NO`) when tracking is in `OPTIN`/`OPTOUT` mode.\n\n</details>"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK` or an error if the argument is not \"yes\" or \"no\".\n\n**RESP3:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK` or an error if the argument is not \"yes\" or \"no\"."
    }
  ],
  "examples": []
}
