invalidateCache( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Clears caches using specified tags.

This function 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 for backend functions using the webMethod() function, and for routers using the ok() function. 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.

Important:

  • If you don't specify any tags in the invalidationsMethod parameter, no caches are invalidated.

  • If you don't use the invalidateCache() function, your caches are only invalidated when the Time to Live (TTL) expires or when you republish your site with a code change.

  • This function can be used to invalidate your backend function caches and router caches. To invalidate Server Side Rendering (SSR) caches for your site, use the invalidateCache() function from the wix-site-backend module.

Method Declaration
Copy
Method Parameters
invalidationMethodsArray<InvalidationMethods>Required

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.


optionsInvalidateCacheOptions
Did this help?