Minor Changes
-
#1378
640e60aThanks @scottbuscemi! - Add an optional distributed object cache for query results.Content reads (
getEmDashCollection,getEmDashEntry,resolveEmDashPath) and chrome reads (site settings, menus, taxonomies) can now be served from a fast key/value store instead of hitting the database on every request. This sits beneath the per-request cache and above the database, dramatically reducing read pressure on D1/SQLite — especially valuable on Cloudflare, where KV handles far more requests than D1.The cache is off by default and fully opt-in. Configure a backend in
astro.config.mjs:import { kvCache } from "@emdash-cms/cloudflare"; // Workers KV (distributed) import { memoryCache } from "emdash/astro"; // in-isolate (Node / local dev) emdash({ database: d1({ binding: "DB" }), objectCache: kvCache({ binding: "CACHE" }), });
with a matching KV binding in
wrangler.jsonc:Invalidation is epoch-based and automatic: content, byline, taxonomy, menu, and settings writes bump a per-namespace version, instantly orphaning stale entries (no key enumeration needed). Preview and visual-edit requests bypass the cache, so editors previewing see live content; other reads are served from the cache, which only ever stores published content. After an edit, anonymous visitors may see stale content until isolates pick up the bumped epoch — immediate on the in-isolate memory backend, and on KV bounded by KV's edge-cache propagation (eventually consistent, up to ~60s) plus the
revalidatewindow (default 1s, configurable).New public API:
cachedQuery,invalidateObjectCache,invalidateCollectionCache,contentNamespace/contentNamespaces,CacheNamespace, theObjectCache*types (fromemdash),memoryCache()(fromemdash/astro), andkvCache()(from@emdash-cms/cloudflare). Existing sites are unaffected until they opt in. -
#1549
a623c6bThanks @ascorbic! - Fixes responsive image optimization for storage-backed media on Cloudflare. EmDash now wraps Astro's image endpoint to read media bytes directly from your storage adapter instead of fetching them over HTTP, soImageand Portable Text images generate a real responsivesrcseteven when the site is behind Cloudflare Access (previously these 404'd and fell back to a full-size image). This is on by default and also removes an internal HTTP round-trip on Node. Setimages: falsein youremdash()config to leave Astro's image endpoint untouched.
{ "kv_namespaces": [{ "binding": "CACHE", "id": "<namespace-id>" }] }