billflare.

风易: What cache fears most is looking up things that do not exist; a crawler scanning random keys makes every request hit D1

On 2026-11-16, X user @Michael_liyang (风易) wrote: what cache fears most is looking up things that do not exist. A crawler scans random keys, penetrates every time, and hits D1 directly, so the cache is added for nothing. The approach is to cache empty results as well, and give the TTL only 5 minutes; log high-frequency nonexistent keys to D1, and blacklist them once confirmed to be a crawler. The chain is request → check cache → return on hit → query D1 on miss → write an empty-value cache if it does not exist. The author's judgment: the cache prevents repeated lookups; it does not block lookups of nonexistent things on the database's behalf.

Products
D1Workers
Source
Author experience𝕏 post
Author
风易 (@Michael_liyang)

Key points

  • This is a new cache-penetration tutorial by this author. It is not merged into the author's existing guides on D1 with no index created, concurrent writes, or batch writes.

Original sources

  1. Published

    Original post

    Read on 𝕏

    On 2026-11-16, X user @Michael_liyang (风易) wrote: what cache fears most is looking up things that do not exist. A crawler scans random keys, penetrates every time, and hits D1 directly, so the cache is added for nothing. The approach is to cache empty results as well, and give the TTL only 5 minutes; log high-frequency nonexistent keys to D1, and blacklist them once confirmed to be a crawler. The chain is request → check cache → return on hit → query D1 on miss → write an empty-value cache if it does not exist. The author's judgment: the cache prevents repeated lookups; it does not block lookups of nonexistent things on the database's behalf.

    风易 | AI 工具链

    @Michael_liyang · Original 𝕏 post

    先说结论:缓存最怕查不存在的东西。爬虫扫随机 key,次次穿透直打 D1,缓存等于白加。 做法:空结果也缓存,TTL 只给 5 分钟;高频不存在的 key 记 D1 日志,确认是爬虫就拉黑。 链路:请求→查缓存→命中返→未命中查 D1→不存在写空值缓存。 判断:缓存防重复查,不替数据库挡不存在的查。
Author experienceWorkers +1

Ru Bite: In Spend Management, turn on Block usage under Billing → Spend limits; limits reset on the subscription billing period, the notification email must be filled in separately, and after Durable Objects are paused storage fees may still continue

On 2026-11-19, X user @JustLikeBit (Ru Bite) wrote a set of notes on metered cloud services having their free quota burned through by bots, and on Cloudflare Spend Management. The author says the entry point is Billing → Spend limits: select Workers or Durable Objects, set a limit, and turn on Block usage; once the limit is hit, supported operations are blocked automatically, and it does not rely only on email alerts. A follow-up adds: limits reset on the subscription billing period, not necessarily on the 1st of each month—for example, if the renewal date is the 15th, counting starts from the 15th; to receive emails at the 80% and 100% thresholds, notification_email must also be configured separately, and setting a limit does not fill in the notification email automatically; after Durable Objects are paused, storage fees for existing data may still continue. The author attached a link to the official documentation. These are the author's restatement of official capabilities and operational reminders, not an actual bill.

D1

hiromsaeden: an unindexed D1 query loop billed $2,129.00; a $953.74 courtesy credit left $645.38 due.

Cloudflare Community user hiromsaeden, in a post-mortem of a personal hobby project on Workers and D1, says an unindexed GROUP BY aggregate query scanned about 877,000 rows to return 30 rows, and an unintended loop triggered about 315,000 runs across two billing cycles. In the Oct 15 – Nov 15 cycle alone, 1,447,580,203,670 rows (1.44 trillion rows) were read, on top of the previous cycle’s usage. The author says the October invoice IN-83890481 was $529.88 USD, paid in full out of pocket; the November invoice IN-89082487 was $1,599.12 USD ($1,447.58 D1 Rows Read + $6.16 Workers CPU + $145.38 tax); and the total billed was $2,129.00 USD against an expected budget of about $20/month. After noticing the issue on Nov 2–3, the author deleted the Worker and the D1 database; Support confirmed all reads had stopped. In case #02408621, Support offered a $275.00 courtesy credit for October and advised holding it until the November invoice was issued on Nov 15. In case #02434399, Support applied a one-time courtesy credit of $953.74 (which included the held $275.00), leaving a final balance of $645.38 USD, and said the review was complete and no further adjustments can be made. The author, having already paid $529.88, says the remaining $645.38 cannot be afforded and the account will be downgraded on Nov 22. The author also says a budget alert fired once at the $37 mark but did not stop the charges, and that D1 currently has no hard spending cap. There is no Cloudflare staff reply on the public thread; the Support actions are reported by the author.

Author experienceObservability +2

Feng Yi: After Observability is billed by write volume, capture all errors and sample only 1%–10% of successful requests; put the body in R2 and set a 7-day expiry

On 2026-11-20, X user @Michael_liyang (Feng Yi), replying to @AdrianPunk115's reminder that from 1 December logs and request tracing will be billed by the volume of data written and stored, wrote: once billing is by write volume, this will change to "capture all errors and sample 1%–10% of successful requests"; a trace keeps only request_id/route/status/duration, and the raw body and prompt go in R2 with a 7-day expiry. The author cautions: estimate bytes written per day before launch, and don't wait for the bill to find that tracing costs more than the business.