whatisgithub

What is cache?

nyraseithhh/cache — explained in plain English

Analysis updated 2026-05-18

39Audience · developerComplexity · 3/5Setup · moderate

In one sentence

A Chinese-language writeup documenting how the authors structured Claude API requests to hit a 96% prompt cache hit rate.

Mindmap

mindmap
  root((Prompt Caching Guide))
    What it does
      Documents cache strategy
      Reports 96 percent hit rate
      Explains sticky routing
    Tech stack
      Claude API
      OpenRouter
    Use cases
      Restructure requests
      Fix sticky routing
      Compare providers
    Audience
      Developers using LLM APIs
    Setup
      Read the guide
      Apply to own request code

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Restructure your AI API requests to put stable content first and volatile content last for better cache hits.

USE CASE 2

Fix a prompt cache that only ever writes and never reads by pinning a user_id for sticky routing.

USE CASE 3

Compare caching setup differences between direct Anthropic, OpenRouter, and OpenAI-compatible proxies.

What is it built with?

Anthropic Claude APIOpenRouter

How does it compare?

nyraseithhh/cacheaa2448208027-code/localaihotswapahxn00/owntv
Stars393939
LanguagePythonKotlin
Setup difficultymoderatemoderateeasy
Complexity3/53/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

This is a documentation repository, not runnable software, applying its advice means restructuring your own API request code.

The excerpt does not state a license, so terms for reuse and redistribution are unclear from the available text.

So what is it?

This repository (written in Chinese) documents the exact prompt caching setup used by its authors to achieve a 96% cache hit rate when calling the Anthropic Claude API. In one measured run, a request with 49,310 input tokens had 47,354 of them served from cache rather than recomputed, saving significant cost and latency. The document explains not what prompt caching is, but specifically how they structured their requests to make that number happen. The core idea is that AI API caching works by matching the beginning of each request byte-for-byte against what was previously seen. If anything changes early in the request, everything after it must be recalculated. So the authors sorted all content by how often it changes, put the most stable content first, and pushed everything that changes each turn to the very end, outside any cached section. They divide the request into four labeled blocks. The first holds the AI persona, language rules, tool descriptions, and long-term memory, because those almost never change. The second holds a daily content file that updates once per day. The third holds a compressed summary of the current conversation session, which is regenerated roughly every 80,000 tokens. The fourth is a rolling marker placed on the second-to-last user message, which pulls all the conversation history into the cache boundary. The final user message, which is new every turn, sits outside any cache marker alongside dynamic content like timestamps and per-turn memory lookups. Beyond the request structure, they discovered that sticky routing matters: if the API load balancer sends different requests to different backend servers, a cache written on one server cannot be read by another. Their fix is to send a fixed user_id in the request metadata so the provider routes all their traffic to the same backend. Without this, they say, the cache only writes and never reads. The document also covers how this setup differs across providers: direct Anthropic connections, OpenRouter, and generic OpenAI-compatible proxies each need slightly different handling. It ends with seven hard-won rules, including keeping the system prompt split into stable and volatile sections, never letting variable content appear before the last cache breakpoint, and keeping tool lists in a fixed order since reordering them breaks the cache prefix.

Copy-paste prompts

Prompt 1
Explain the four-block request structure this document describes for maximizing Claude prompt cache hits.
Prompt 2
Help me add a fixed user_id to my API requests to fix sticky routing for prompt caching.
Prompt 3
Summarize the seven rules this document lists for keeping a prompt cache from breaking.
Prompt 4
Explain why reordering my tool list in a request would break prompt caching.

Frequently asked questions

What is cache?

A Chinese-language writeup documenting how the authors structured Claude API requests to hit a 96% prompt cache hit rate.

What license does cache use?

The excerpt does not state a license, so terms for reuse and redistribution are unclear from the available text.

How hard is cache to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is cache for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.