{
  "schema_version": 2,
  "id": "commands/client-tracking",
  "title": "CLIENT TRACKING",
  "url": "https://redis.io/docs/latest/commands/client-tracking/",
  "summary": "Controls server-assisted client-side caching for the connection.",
  "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": "414a23996ccf44e7284d06c08d6c7b8540ba23a4f47c7efbfcfa9f396ef3a200",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command enables the tracking feature of the Redis server, which is used\nfor [server assisted client side caching](https://redis.io/docs/latest/develop/clients/client-side-caching#tracking).\n\nWhen tracking is enabled Redis remembers the keys that the connection\nrequested, in order to send later invalidation messages when such keys are\nmodified. Invalidation messages are sent in the same connection (only available\nwhen the RESP3 protocol is used) or redirected in a different connection\n(available with RESP2 and Pub/Sub). You can use broadcasting mode to receive notifications for all keys that match the key prefixes you subscribe to, regardless of which keys you request. For details, see [the client-side caching documentation](https://redis.io/docs/latest/develop/reference/client-side-caching). This page only describes the options for this subcommand.\n\nIn order to enable tracking, use:\n\n    CLIENT TRACKING ON ... options ...\n\nThe feature will remain active in the current connection for all its life,\nunless tracking is turned off with `CLIENT TRACKING OFF` at some point."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>ON | OFF</code></summary>\n\nTurn key-invalidation tracking on or off for the connection.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>REDIRECT client-id</code></summary>\n\nSend invalidation messages to the connection with the specified ID. The connection must exist. You can get the ID of a connection using [`CLIENT ID`](https://redis.io/docs/latest/commands/client-id). If the redirected connection terminates while in RESP3 mode, the connection with tracking enabled receives tracking-redir-broken push messages to signal the disconnection.\n\n</details>\n\n<details open><summary><code>PREFIX prefix [PREFIX prefix ...]</code></summary>\n\nTrack only keys that start with one of the specified prefixes. Use with the `BCAST` argument. You can specify this option multiple times to track multiple prefixes. If you enable broadcasting without this option, Redis sends invalidation messages for every key. You can’t remove a single prefix; to remove all prefixes, disable and re-enable tracking. This option adds O(N^2) time complexity, where N is the total number of tracked prefixes.\n\n</details>\n\n<details open><summary><code>BCAST</code></summary>\n\nEnable broadcasting mode. In this mode, Redis sends invalidation messages for all keys, or for keys that match a specified PREFIX, instead of only the keys that the connection reads. Without broadcasting mode, Redis tracks the keys fetched by read-only commands and sends invalidation messages only for those keys.\n\n</details>\n\n<details open><summary><code>OPTIN</code></summary>\n\nTrack keys only for read commands that immediately follow a `CLIENT CACHING YES`.\n\n</details>\n\n<details open><summary><code>OPTOUT</code></summary>\n\nTrack all read keys except those for commands that immediately follow a `CLIENT CACHING NO`.\n\n</details>\n\n<details open><summary><code>NOLOOP</code></summary>\n\nDo not send invalidation messages for keys modified by this connection. In the default tracking mode, modifying a tracked key removes it from the invalidation table, even when `NOLOOP` suppresses the message. To track the key for future invalidations, read the key again.\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` if the connection was successfully put in tracking mode or if the tracking mode was successfully disabled. Otherwise, an error is returned.\n\n**RESP3:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK` if the connection was successfully put in tracking mode or if the tracking mode was successfully disabled. Otherwise, an error is returned."
    }
  ],
  "examples": []
}
