본문 바로가기
C.W.K.
Stream
Lesson 02 of 05 · published

Cache Buster: Top 5

~23 min · cache-busting, timestamps, tool-schemas

Level 0Window Watcher
0 XP0/50 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

작은 차이도 비싸게 먹혀

prefix를 글자 그대로 맞춰보기 때문에, 별것 아니어 보이는 차이가 cache를 통째로 날려. 맨 위 timestamp, 아무 request ID, 뒤죽박죽인 JSON key 순서, 매번 새로 만들어지는 tool schema, 계속 바뀌는 example 같은 것들. 비싼 건 변하는 내용 자체가 아니야. 그 변하는 내용을 다시 쓸 prefix가 끝나기 전에 놓는 게 비싼 거지.

Cache 깨먹는 다섯 가지

1. 첫 줄의 timestamp나 request ID. 2. key 순서가 매번 달라지는 채로 새로 만들어지는 tool schema. 3. 요청마다 다시 섞이는 example. 4. 규칙 위에 붙는 '오늘의 팁'이나 돌아가는 배너. 5. prefix 영역 안 규칙 구획에 사용자 이름이나 현재 시각이 끼어든 인사말.

변하는 건 변한다고 티를 내

변하는 자료는 전부 tail 구획 아래로 몰아. timestamp가 꼭 필요하면 거기 둬. tool schema가 바뀌면 일부러 버전을 올려. 정렬 안 된 key가 소리 없이 byte를 바꾸게 두지 말고.

Code

흔한 cache 훼방꾼·yaml
cache_busters:
  - "timestamp in first line"
  - "random request id before tool schemas"
  - "unsorted JSON schema keys (Python dict ordering quirk)"
  - "rewritten examples every request"
  - "changing image detail parameter"
  - "user name interpolated into rules section"
JSON schema 고정시키기·python
import json
schema_text = json.dumps(SCHEMA, sort_keys=True, indent=2)
# Now every request produces byte-identical schema text -> cache hit.

External links

Exercise

prompt나 요청 만드는 코드에서 cache 훼방꾼 셋을 찾아봐. tail로 옮기든가 안 바뀌게 고정하든가 해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.