About Caching Data Query Results

Data caching significantly speeds up data queries. Wix automatically caches the results of certain data queries to a Content Delivery Network (CDN). When a visitor makes a query whose results are cached, Wix provides the cached results instead of querying the database again.

When does data caching occur?

Whether the results of a data query are cached depends on several factors.

Which data query results are cached?

Data query results are only cached when:

Which data request results are not cached?

Results of data requests are not cached when:

Data cache invalidation

The data cache is automatically cleared whenever a request makes changes to a collection or any of its items. Any cached results that reference the modified collection are also cleared. In addition, cached results are cleared after one week. This automatic cache invalidation allows new, updated data to be cached and returned to visitors in future queries.

To make the best of Wix's data caching, avoid frequent or unnecessary cache invalidations. This might require splitting some collections into two separate collections: one that contains data likely to change frequently, and another whose data is not likely to be modified often, so its associated cache is less likely to be invalidated.

Cache invalidation and eventual consistency

Since cache invalidation might take a few seconds to complete, it increases the chance that out-of-date data could be returned to site visitors. This can make the effects of eventual consistency more noticeable.

To ensure that query results contain the most up-to-date data, you can override eventual consistency. When running the data query using find(), count(), or distinct(), set the options.consistentRead parameter to true. For example:

Copy

Data caching and site monitoring

Wix's site monitoring dashboard allows site collaborators to view and analyze site performance. At present, user requests that are served cached results are monitored but not displayed on the dashboard.

See also

Did this help?