> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: About Caching Data Query Results ## Article: About Caching Data Query Results ## Article Link: https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results.md ## Article Content: # 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: - The query does not modify the collection or any of its items. - The collection permissions do not allow [anonymous site visitors to add, update, or delete items](https://support.wix.com/en/article/cms-collection-permissions-overview#use-the-show-content-permission-for-view-only-access). - The queried collection is a [native Wix Data collection](https://support.wix.com/en/article/cms-formerly-content-manager-creating-a-collection). - The query does not trigger any [data hooks](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/hooks/about-data-hooks.md). - The request is made by code that runs on the [site frontend](https://dev.wix.com/docs/develop-websites/articles/get-started/website-development-features.md). - The request is made on behalf of a [site visitor](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-identities.md). - The request does not contain [Personally Identifiable Information (PII)](https://support.wix.com/en/article/about-personally-identifiable-information-pii). - [Eventual consistency](#cache-invalidation-and-eventual-consistency) is not overridden. - The collection does not have [item visibility](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection) enabled. ### Which data request results are not cached? Results of data requests are not cached when: - The request modifies the collection or the items it contains, such as by calling [`insert()`](https://dev.wix.com/docs/velo/apis/wix-data/insert.md) or [`remove()`](https://dev.wix.com/docs/velo/apis/wix-data/remove.md). - The collection permissions [allow site visitors to add, update, or delete items](https://support.wix.com/en/article/cms-collection-permissions-overview#set-advanced-permissions-for-more-access-control). - The data request is to a [Wix app collection](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code.md), an [external collection](https://dev.wix.com/docs/develop-websites/articles/databases/external-databases/overview/integrating-external-databases-with-your-wix-site.md), or to a [shared collection](https://support.wix.com/en/article/wix-enterprise-sharing-cms-collections-with-sites-and-templates). - The request triggers a [data hook](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/hooks/about-data-hooks.md). - The request is made by code that runs on the [site backend](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend.md). - The data request is made on behalf of a [site member](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-identities.md). - The request contains [Personally Identifiable Information (PII)](https://support.wix.com/en/article/about-personally-identifiable-information-pii). - [Eventual consistency](#cache-invalidation-and-eventual-consistency) is overridden. - The collection has [item visibility](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection) enabled. ## Data cache invalidation Cache invalidation allows new, updated data to be cached and returned to visitors in future queries. The cache is automatically cleared when: - A request makes changes to the collection or to any of its items. Any cached results that reference the modified collection are also cleared. - The [site is published](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/overview/publishing-your-site.md). - Results have been cached for one week or longer. 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](https://dev.wix.com/docs/velo/apis/wix-data-v2/eventual-consistency.md) more noticeable. To ensure that query results contain the most up-to-date data, you can override [eventual consistency](https://dev.wix.com/docs/velo/apis/wix-data-v2/eventual-consistency.md). When running the data query using [`find()`](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query/find.md), [`count()`](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query/count.md), or [`distinct()`](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query/distinct.md), set the `options.consistentRead` parameter to `true`. For example: ```js import { items } from "@wix/data"; async function findItems() { const results = await items.query("myCollection").find({ consistentRead: true, }); } ``` ## Data caching and site monitoring Wix's [site monitoring dashboard](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/testing-monitoring/monitoring-your-published-site/working-with-the-monitoring-dashboard.md) 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 - [Wix data and eventual consistency](https://dev.wix.com/docs/velo/apis/wix-data-v2/eventual-consistency.md) - [Working with Wix app collections and code](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code.md) - [Working with the monitoring dashboard](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/testing-monitoring/monitoring-your-published-site/working-with-the-monitoring-dashboard.md) - [About page caching](https://dev.wix.com/docs/develop-websites/articles/best-practices/caching/about-page-caching.md)