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.
Whether the results of a data query are cached depends on several factors.
Data query results are only cached when:
Results of data requests are not cached when:
insert()
or remove()
.Cache invalidation allows new, updated data to be cached and returned to visitors in future queries. The cache is automatically cleared when:
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.
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:
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.