> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: invalidateCache(invalidationMethods: Array<InvalidationMethods>, options: InvalidateCacheOptions)

# Method package: wixCacheBackend

# Method menu location: wixCacheBackend --> cache --> invalidateCache

# Method Link: https://dev.wix.com/docs/velo/apis/wix-cache-backend/cache/invalidate-cache.md

# Method Description:

>**Note:** This API is only supported when developing a site.

Invalidates or clears previously cached return values based on specified tags.

The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values of web methods ([Velo](https://dev.wix.com/docs/velo/api-reference/wix-web-module/web-method.md) | [SDK](https://dev.wix.com/docs/sdk/core-modules/web-methods/web-method.md)), and for routers (currently [Velo](https://dev.wix.com/docs/velo/api-reference/wix-router/ok.md) only).

For example, an array such as `[{ tag: "contacts" }, { tag: "labels" }]` will clear any cached return values tagged with "contacts" or "labels."

Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.

<blockquote class="important">

__Important:__
- If you don't specify any tags in the `invalidationsMethod` parameter, no caches are invalidated.
- If you don't call Invalidate Cache, caches are only invalidated when the Time to Live (TTL) expires or when the site is republished with a code change.


- (Velo only) Call Invalidate Cache to invalidate your web method and router caches. To invalidate Server Side Rendering (SSR) caches for your site, use the `invalidateCache()` function from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache.md) module.

</blockquote>



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Cache the value returned from a function, then invalidate it 

```javascript
import { cache } from "wix-cache-backend";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";

// Cache the return value
export const cachedMultiply = webMethod(Permissions.Anyone, (a, b) => a * b, {
  cache: {
    tags: ["multiply", "math"],
    ttl: 604000,
  },
});


// Invalidate the cache
const invalidationMethods = [{ tag: "multiply" }, { tag: "math" }];
const elevatedInvalidateCache = elevate(cache.invalidateCache);

export const invalidateCache = webMethod(Permissions.Anyone, async () => {
  try {
    await elevatedInvalidateCache(invalidationMethods);
    console.log("Successfully invalidated cache.")
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/* Promise resolves to void */
```

## Invalidate cached return value from queryContacts()

```javascript
import { cache } from "wix-cache-backend";
import { contacts } from "wix-crm.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";

// Query contacts and cache result
const elevatedQueryContact = elevate(contacts.queryContacts);

export const myQueryContactFunction = webMethod(
  Permissions.Anyone,
  async () => {
    try {
      const contact = await elevatedQueryContact().find();
      return contact.items;
    } catch (error) {
      console.log(error);
      // Handle the error
    }
  },
  {
    cache: {
      tags: ["contact", "crm"],
      ttl: 85500,
    },
  }
);



// Invalidate cached query return value
/* Sample invalidationMethods value:
 * [
 *   { tag: "contact" },
 *   { tag: "crm" }
 * ]
 */
const elevatedInvalidateCache = elevate(cache.invalidateCache);

export const invalidateCache = webMethod(
  Permissions.Anyone,
  async (invalidationMethods) => {
    try {
      await elevatedInvalidateCache(invalidationMethods);
      return console.log("Successfully invalidated cache.");
    } catch (error) {
      console.error(error);
      // Handle the error
    }
  }
);

```

---