跳到正文
北京时间
原文
ClaudeDevs· @ClaudeDevs · X·· 2026-05-15精选AI 评分70
AI 导读

减少API长提示首令牌生成时间的实用技巧:预热提示缓存。 在用户提示前发送系统提示。Claude会将其写入缓存,但跳过生成任何输出。 当真实用户请求到达时,将直接命中预热缓存。

推荐理由

官方给出的 prompt cache 预热技巧,一行代码优化延迟,做长上下文 API 产品的开发者可以直接抄进流程里。

正文 · 原文

Useful tip to cut time-to-first-token on longer prompts in the API: pre-warm the prompt cache.

Send your system prompt before the user prompt. Claude writes it to the cache, but skips generating any output.

When the real user request lands, it'll hit a warm cache.

来源:ClaudeDevs · x.com