> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # invalidateCache # Package: viewer # Namespace: InvalidateCacheService # Method link: https://dev.wix.com/docs/api-reference/site/viewer/cache/invalidate-cache.md ## Introduction
__Important:__ This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.
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 site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction.md) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction.md#events-service-plugins_routers_service-plugins_wix-router_router-caching). 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. >**Notes:** >- If you don't specify any tags in the `invalidationMethods` 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. >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache.md) module. --- ## REST API ### Schema ``` Method: invalidateCache Description:
__Important:__ This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.
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 site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction.md) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction.md#events-service-plugins_routers_service-plugins_wix-router_router-caching). 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. >**Notes:** >- If you don't specify any tags in the `invalidationMethods` 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. >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache.md) module. URL: https://www.wixapis.com/ssr/v1/invalidate-cache Method: POST Method parameters: param name: invalidationMethods | type: array | description: An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. - ONE-OF: - name: tag | type: string | description: *Required.** Identifier of the caches to invalidate. Return type: InvalidateCacheResponse EMPTY-OBJECT {} ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.viewer.InvalidateCacheService.invalidateCache(invalidationMethods) Description:
__Important:__ This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.
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 site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction.md) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction.md#events-service-plugins_routers_service-plugins_wix-router_router-caching). 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. >**Notes:** >- If you don't specify any tags in the `invalidationMethods` 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. >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache.md) module. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: invalidationMethods Method parameters: param name: invalidationMethods | type: array | description: An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. | required: true - ONE-OF: - name: tag | type: string | description: *Required.** Identifier of the caches to invalidate. Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### invalidateCache ```javascript import { cache } from '@wix/cache'; async function invalidateCache(invalidationMethods) { const response = await cache.invalidateCache(invalidationMethods); }; ``` ### invalidateCache (with elevated permissions) ```javascript import { cache } from '@wix/cache'; import { auth } from '@wix/essentials'; async function myInvalidateCacheMethod(invalidationMethods) { const elevatedInvalidateCache = auth.elevate(cache.invalidateCache); const response = await elevatedInvalidateCache(invalidationMethods); } ``` ### invalidateCache (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { cache } from '@wix/cache'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { cache }, // Include the auth strategy and host as relevant }); async function invalidateCache(invalidationMethods) { const response = await myWixClient.cache.invalidateCache(invalidationMethods); }; ``` ---