Skip to content

未作成の期間の404を長時間キャッシュしないようにする - #235

Merged
kojira merged 1 commit into
mainfrom
claude/ranking-feature-bug-a8nq2k
Aug 2, 2026
Merged

未作成の期間の404を長時間キャッシュしないようにする#235
kojira merged 1 commit into
mainfrom
claude/ranking-feature-bug-a8nq2k

Conversation

@kojira

@kojira kojira commented Aug 2, 2026

Copy link
Copy Markdown
Member

背景

rankingArchiveGo の詳細取得で、キャッシュ指定を中身を見る前に立てていた。

w.Header().Set("Cache-Control", "public, max-age=600, s-maxage=86400, ...")
resp, err := loadArchiveDetail(...)
...
if resp == nil {
    writeError(w, http.StatusNotFound, "period not found")  // ← 404 も同じヘッダで返る
    return
}

そのためまだ締めていない期間を引いた 404 が s-maxage=86400 で共有キャッシュに載り、
後から締めても丸一日「無い」と返り続ける

2026-07 を遡って作ったときに実際に踏んでいる。復元中に何度か確認のため叩いており、
その 404 が Fastly の POP に残っている:

HTTP/2 404
cache-control: public, max-age=600, s-maxage=86400, stale-while-revalidate=86400
{"message":"period not found","status":"failed"}

一覧が空のときに同じことが起きた(#231)のと同じ種類の穴。あちらだけ直して、
詳細側が残っていた。

変更

archiveDetailCacheControl(found bool) を切り出し、キャッシュ指定は
loadArchiveDetail の結果が分かってから立てる。見つからなかったときは
一覧の空と同じく30秒。

テスト

TestArchiveDetailCacheControl を追加(未作成は短命/締め済みは長命)。

Co-Authored-By: Claude Opus 5 noreply@anthropic.com


Generated by Claude Code

過去ランキング詳細のキャッシュ指定を、中身を見る前に立てていた。そのため
まだ締めていない期間を引いた404が s-maxage=86400 で共有キャッシュに載り、
後から締めても丸一日「無い」と返り続ける状態だった。2026-07 を遡って作った
ときに実際に踏んでいる。

一覧が空のとき(#231)と同じ扱いにし、見つからなかった場合だけ短命にする。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@kojira
kojira merged commit 70ea220 into main Aug 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant