中文

Field Notes & TILs

Short, high-signal observations from building with LLMs, Cloudflare Workers, and local Apple Silicon inference.

#astro #giscus #performance

Zero-Cost Lazy Giscus Comments with Live Theme Sync

For developer and AI research blogs, pairing IntersectionObserver + postMessage keeps Giscus completely free of performance or database overhead:

  1. Never load giscus.app/client.js on initial page paint—inject it only when the reader scrolls within 280px of the comment container.
  2. Listen for theme toggles and dispatch postMessage({ giscus: { setConfig: { theme } } }, 'https://giscus.app') so light/dark mode switches instantaneously without reloading the iframe.
#cloudflare #finops

Why You Should Never Cache HTML Pages in Cloudflare Workers KV

Many tutorials store rendered HTML strings in Workers KV, which quickly breaks on the $0 Free Tier:

  • Workers KV Free allows only 1,000 writes/day. A single search-bot crawl across localized routes will exhaust KV.put() quota within hours.
  • Better pattern: Prefer build-time SSG (Workers Static Assets, zero quota usage). When dynamic edge caching is truly needed, use caches.default (Cache API) with s-maxage + stale-while-revalidate headers—zero KV writes consumed.