Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable local cache for /api/thumbnails/{thumbnailId} #707

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

fetburner
Copy link
Contributor

Why

EPGStation v2.10.0 では、/api/thumbnails/{thumbnailId} のレスポンスには Cache-Control ヘッダが設定されておらず、番組のサムネイルが表示される度にサーバーへリクエストが飛ぶ状態にあります。

GiZJpW3aYAAbzO0

サムネイルとはいえ著作権保護されたコンテンツの一部なので共有キャッシュへ保存すべきでないのは分かるのですが、EPGStation をブラウザで開いているユーザーのローカルにはキャッシュしても良いのではないでしょうか?

概要(Summary)

/api/thumbnails/{thumbnailId} のレスポンスにおける Cache-Control ヘッダに private, max-age=14400 を設定し、番組のサムネイルが4時間程度はローカルのキャッシュに保存されるようにします。

動作確認

アクセス制限を施した上で Cloudflare の CDN を通じて EPGStation v2.10.0 にアクセスする環境において、Cache-Control ヘッダに private, max-age=14400 が設定されサムネイルがローカルにキャッシュされることと、Cloudflare の CDN にはキャッシュされていない事を確認しました。

スクリーンショット 2025-01-30 0 25 44

ここで、Cf-Cache-StatusDYNAMIC に設定されていますが、これは Cloudflare の CDN がキャッシュ対象と見做していない事を示しています。 cf. https://developers.cloudflare.com/cache/concepts/cache-responses/#dynamic

@fetburner fetburner changed the base branch from master to v2 January 29, 2025 15:44
@@ -15,6 +15,7 @@ export const get: Operation = async (req, res) => {
message: 'thumbnail is not Found',
});
} else {
res.header('Cache-Control', 'private, max-age=14400');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここで max-age=14400 としたのは EPGStation のアイコンがキャッシュされる時間に揃えただけで、キャッシュ期間に深い意味はありません。

スクリーンショット 2025-01-30 0 46 30

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