About the Cache API

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

The Cache API provides functionality for invalidating site web method and router caches. Note that app web methods cannot cache their responses.

Consider invalidating your caches when there are significant changes to your site's content. For example, if a product on your e-commerce site becomes out of stock, you should invalidate the cache of the web method that retrieves and displays the product, ensuring that visitors see the most current status.

Learn more about caching.

Before you begin

It's important to note the following before you begin to code:

  • This API is only supported for developing sites.
  • This API works only when used together with the Web Methods or Router APIs.
  • You can only use this API to invalidate caches that were previously defined with tags.
  • A cache is automatically invalidated when:
    • The cache's time to live (TTL) expires.
    • You republish your site with a code change.

Terminology

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