---
title: Guide - Cache Revalidation
sidebar_label: Cache Revalidation
---

# Cache Revalidation

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

When using the application, `we often encounter the need to revalidate data`. This is because of various
`dynamic changes` in the case of the users interacting with our applications. For example, when deleting a note from the
list of notes in the database, we want the already stored data to be refreshed. In this case, we use cache revalidation.

We can do it by using appropriate methods. Passing an **`invalidationKey`** which should be a `cacheKey or RegExp` that
will allow us to find the desired key of the data stored in cache.

---

<Tabs>
  <TabItem value="React" label="React" default>

```tsx
// With useFetch
const { revalidate } = useFetch(getUsers);

// Refresh used request
revalidate()
// or
revalidate(getNotes)
// or
revalidate(getNotes.cacheKey)
// or
revalidate(new RegExp(...))

// With useSubmit
const { revalidate } = useSubmit(getUsers);

revalidate(getNotes)
// or
revalidate(getNotes.cacheKey)
// or
revalidate(new RegExp(...))


// With useCache
const { revalidate } = useCache(getUsers);

// Refresh used request
revalidate()
// or
revalidate(getNotes)
// or
revalidate(getNotes.cacheKey)
// or
revalidate(new RegExp(...))
```

  </TabItem>
  <TabItem value="Typescript" label="Typescript" default>

```ts
client.cache.revalidate(getNotes.cacheKey)
// or
client.cache.revalidate(new RegExp(...))
```

  </TabItem>
</Tabs>
