About Caches

Developer Preview
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.

 

Caching allows you to temporarily store the return values of backend API calls and successful router calls on Wix's infrastructure, enabling quicker access to the data and improved site performance. While caching is effective, it’s important to invalidate caches when necessary to ensure that data always remains up to date. This helps preserve accuracy and prevents visitors from seeing outdated content.

The Cache API provides functionality for invalidating web method caches and router caches. Consider invalidating your caches when there are significant changes to your site's content or when your site pages display time-sensitive data. For example, if a product on your e-commerce site becomes out of stock, invalidating the cache of the web method that displays your products ensures that visitors see the most current status.

Learn more about web method caching and router caching.

To use the Cache API, import cache from the wix-cache-backend module:

Copy

Before you begin

You can invalidate your caches that were previously defined with tags. Your cache is automatically invalidated when:

  • The cache's time to live (TTL) expires.
  • You republish your site with a code change.

Permissions information

Functions in the Cache API are restricted and only run if you elevate permissions using the wix-auth elevate() function.

Warning: Elevating a function allows it to be called by any site visitor. Exercise caution to prevent security vulnerabilities.

Terminology

  • Cache: Return value data that is temporarily stored on Wix's infrastructure.
  • Tag: Used to identify which caches to invalidate.
Did this help?