extract metadata from redirect headers to avoid redundant WB req #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
https://redmine.devops.rcos.nii.ac.jp/issues/55671
https://redmine.devops.rcos.nii.ac.jp/issues/55665
Purpose
ファイルレンダラーのパフォーマンス最適化を目的としたプルリクエストです。OSFからのメタデータ取得を効率化し、不要なリクエストを削減します。
Changes
メタデータキャッシング機構の導入
_cached_metadata フィールドを追加してメタデータをキャッシュ
metadata メソッドでキャッシュの有無を最初にチェック
キャッシュが存在する場合は、WaterButler APIへのリクエストをスキップ
メトリクスに 'cached_from_head' を記録
HTTPメソッドの変更
_fetch_download_url メソッドのリクエストを GET → HEAD に変更
HEADリクエストはボディを含まないため、通信量を削減
レスポンスヘッダーから X-File-Metadata を取得して _cached_metadata に保存
処理フローの改善
変更前: GETリクエスト → WaterButler APIでメタデータ取得
変更後: HEADリクエスト → ヘッダーからメタデータ取得 → キャッシュ使用
Side effects
連携する変更(RDM-osf.io #612)
このプルリクエストは、RDM-osf.io #612 で追加された X-File-Metadata ヘッダーを活用します:
osf.io側: HEADリクエストのレスポンスに X-File-Metadata ヘッダーを追加
file-renderer側: そのヘッダーからメタデータを取得してキャッシュ
QA Notes
Deployment Notes
RDM-osf.io #612 → S3リージョン情報の保存とヘッダー追加
RDM-waterbutler CenterForOpenScience#79 → リージョン情報の活用
RDM-modular-file-renderer #6 → メタデータキャッシュの活用