0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

静的コンテンツ配信の最適化:S3とCloudFrontの分担

0
Posted at

静的コンテンツを効率的に配信することは、ウェブアプリケーションのパフォーマンスとユーザーエクスペリエンスを向上させる重要な要素です。Amazon S3とAmazon CloudFrontは、静的コンテンツのホスティングと配信を容易にするAWSのサービスです。この記事では、S3とCloudFrontを使用して静的配信を実現する際の分担について説明します。

S3の役割

Amazon S3は、静的コンテンツを格納するためのオブジェクトストレージサービスです。S3バケットを作成して静的ファイル(HTML、CSS、JavaScript、画像など)をアップロードすると、ウェブサイトのコンテンツを安全かつスケーラブルにホストできます。

# S3バケットを作成する
aws s3 mb s3://example-bucket

# 静的ファイルをアップロードする
aws s3 cp index.html s3://example-bucket/

CloudFrontの役割

Amazon CloudFrontは、静的コンテンツをエッジロケーションにキャッシュして配信するコンテンツ配信ネットワーク(CDN)サービスです。CloudFrontを使用すると、ユーザーの近くにコンテンツを配信できるため、ウェブサイトのロード時間を短縮できます。

# CloudFrontディストリビューションを作成する
aws cloudfront create-distribution --origin-domain-name example-bucket.s3.amazonaws.com

# CloudFrontディストリビューションを更新する
aws cloudfront update-distribution --distribution-config '{"Origins": {"Quantity": 1, "Items": [{"Id": "example-bucket", "DomainName": "example-bucket.s3.amazonaws.com"}]}}'

S3とCloudFrontの分担

S3とCloudFrontを組み合わせて使用すると、静的コンテンツのホスティングと配信を最適化できます。S3は静的ファイルのホスティングに使用され、CloudFrontはそれらのファイルをエッジロケーションにキャッシュして配信します。

+---------------+
|  ユーザー  |
+---------------+
           |
           |
           v
+---------------+
| CloudFront  |
+---------------+
           |
           |
           v
+---------------+
|     S3      |
+---------------+

このアーキテクチャでは、ユーザーはCloudFrontのエッジロケーションにアクセスして静的コンテンツを要求し、CloudFrontはS3からコンテンツを取得してユーザーに配信します。

詳しい手順はこちら → https://felixstudio0.gumroad.com/?utm_source=qiita&utm_medium=github_actions&utm_campaign=2026-q1&utm_content=qiita-footer

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?