#Astro content loader, config persistence
11 messages · Page 1 of 1 (latest)
Hi @sinful prairie. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro’s content loader API provides a KV store called the DataStore for storing and retrieving the actual content entries of a collection. However, for storing loader-specific configuration or metadata—such as a repository revision to avoid refetching everything—Astro provides a separate key-value store called meta, available as the meta property on the LoaderContext object passed to your loader’s load() method.
You can use meta to persist values like sync tokens, last-modified times, or repository revisions between builds. This metadata is scoped to the collection and is persisted alongside the collection data, but is only available inside the loader:
const lastRevision = meta.get("lastRevision");
// ... fetch new data if needed ...
meta.set("lastRevision", newRevision);
This allows you to store and retrieve the repository revision (or any other loader-specific state) without having to refetch the entire repository each time the loader runs. The meta store is designed exactly for this use case and is documented in the Astro Content Loader API reference LoaderContext and MetaStore sections.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@sinful prairie Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@modest notch does Astro have a mechanism/command to clear that meta store?
Let me check the knowledge base for you again. One moment! :books:
I'm sorry, but the knowledge sources do not explicitly mention any Astro mechanism or CLI command to clear the meta store used by the content loader API. The documentation describes how to use the meta store within a loader to get and set metadata, but does not provide information about clearing or resetting it outside of the loader context LoaderContext.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@sinful prairie Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@modest notch what about a command for resetting/clearing all data from content loaders? not just the meta store
Let me check the knowledge base for you again. One moment! :books:
Astro does not provide a dedicated CLI command specifically for resetting or clearing all data from content loaders (including both the content and the meta store) according to the available documentation. However, you can force a full rebuild of the content layer—which will clear the content layer cache—by using the --force flag with commands like astro dev or astro build:
astro dev --force
This flag is documented as clearing the content layer cache, which would trigger a full reload of your content collections and their loaders. While the documentation does not explicitly state that this also clears the meta store, it is the closest mechanism described for resetting loader data Common flags.