{"id":3627,"date":"2026-10-30T06:00:38","date_gmt":"2026-10-29T21:00:38","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=3627"},"modified":"2026-10-30T06:00:38","modified_gmt":"2026-10-29T21:00:38","slug":"20260914-00mu0ksb","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2026\/10\/30\/20260914-00mu0ksb\/","title":{"rendered":"CloudFront + S3 \u3067 SPA \u3092\u3061\u3083\u3093\u3068\u914d\u4fe1\u3059\u308b"},"content":{"rendered":"<h2>\u6982\u8981<\/h2>\n<p>React \/ Vue \u306a\u3069\u306e SPA\uff08Single Page Application\uff09\u3092\u672c\u756a\u914d\u4fe1\u3059\u308b\u5b9a\u756a\u69cb\u6210\u304c\u300cS3 \u306b\u30d3\u30eb\u30c9\u6210\u679c\u7269\u3092\u7f6e\u304d\u3001CloudFront \u304b\u3089\u914d\u4fe1\u3059\u308b\u300d\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002\u624b\u9806\u81ea\u4f53\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u304c\u3001\u7d20\u76f4\u306b\u4f5c\u308b\u3068\u6b21\u306e\u3088\u3046\u306a\u843d\u3068\u3057\u7a74\u306b\u30cf\u30de\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30ea\u30ed\u30fc\u30c9\u3059\u308b\u3068 403 \/ 404 \u306b\u306a\u308b\uff08SPA \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u7f60\uff09<\/li>\n<li><code>index.html<\/code> \u304c\u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u7d9a\u3051\u3066\u30c7\u30d7\u30ed\u30a4\u304c\u53cd\u6620\u3055\u308c\u306a\u3044<\/li>\n<li>S3 \u3092\u516c\u958b\u8a2d\u5b9a\u306b\u3057\u3066\u3057\u307e\u3044\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u7684\u306b\u4e0d\u5b89\u304c\u6b8b\u308b<\/li>\n<\/ul>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<strong>S3 \u30d0\u30b1\u30c3\u30c8\u3092\u975e\u516c\u958b\u306e\u307e\u307e<\/strong>\u3001OAC\uff08Origin Access Control\uff09\u3067 CloudFront \u304b\u3089\u306e\u307f\u30a2\u30af\u30bb\u30b9\u3055\u305b\u3001SPA \u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u307e\u3067\u542b\u3081\u3066\u914d\u4fe1\u3059\u308b\u69cb\u6210\u3092\u30cf\u30f3\u30ba\u30aa\u30f3\u5f62\u5f0f\u3067\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n<h2>\u74b0\u5883<\/h2>\n<ul>\n<li>AWS \u30a2\u30ab\u30a6\u30f3\u30c8\uff08\u691c\u8a3c\u7528\u306e\u500b\u4eba\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u60f3\u5b9a\uff09<\/li>\n<li>AWS CLI v2<\/li>\n<li>Node.js 20 \u4ee5\u4e0a<\/li>\n<li>\u914d\u4fe1\u3059\u308b\u3082\u306e: \u4efb\u610f\u306e SPA \u306e\u30d3\u30eb\u30c9\u6210\u679c\u7269\uff08<code>dist\/<\/code> \u307e\u305f\u306f <code>build\/<\/code>\uff09<\/li>\n<li>\u30ea\u30fc\u30b8\u30e7\u30f3: \u6771\u4eac\uff08<code>ap-northeast-1<\/code>\uff09\u3092\u57fa\u672c\u3002\u305f\u3060\u3057\u5f8c\u8ff0\u306e\u7406\u7531\u3067 ACM \u8a3c\u660e\u66f8\u306e\u307f <code>us-east-1<\/code><\/li>\n<\/ul>\n<p>\u69cb\u6210\u56f3\uff08\u62bd\u8c61\u5316\u3057\u305f\u30ec\u30d9\u30eb\uff09:<\/p>\n<pre class=\"lang:default decode:true\">\u30e6\u30fc\u30b6\u30fc\n  \u2502  HTTPS\n  \u25bc\nCloudFront (Distribution)\n  \u2502  OAC \u3067\u7f72\u540d\u4ed8\u304d\u30ea\u30af\u30a8\u30b9\u30c8\n  \u25bc\nS3 (\u975e\u516c\u958b\u30d0\u30b1\u30c3\u30c8 \/ \u9759\u7684\u30a2\u30bb\u30c3\u30c8)<\/pre>\n<h2>\u767a\u751f\u3057\u305f\u554f\u984c<\/h2>\n<p>SPA \u3092\u300c\u3068\u308a\u3042\u3048\u305a\u914d\u4fe1\u300d\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u6b21\u306e 3 \u3064\u306b\u5fc5\u305a\u3076\u3064\u304b\u308a\u307e\u3059\u3002<\/p>\n<h3>1. \u30ea\u30ed\u30fc\u30c9\u3067 404 \u306b\u306a\u308b<\/h3>\n<p>SPA \u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3067\u3059\u3002<code>\/users\/123<\/code> \u306e\u3088\u3046\u306a URL \u3092\u76f4\u63a5\u958b\u304f\u3068\u3001S3 \u306b\u306f <code>users\/123<\/code> \u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5b58\u5728\u3057\u306a\u3044\u305f\u3081 404\uff08\u30d0\u30b1\u30c3\u30c8\u30dd\u30ea\u30b7\u30fc\u6b21\u7b2c\u3067\u306f 403\uff09\u304c\u8fd4\u308a\u307e\u3059\u3002\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304b\u3089\u306e\u9077\u79fb\u3067\u306f\u52d5\u304f\u306e\u306b\u3001\u30ea\u30ed\u30fc\u30c9\u3084URL\u76f4\u6253\u3061\u3060\u3051\u58ca\u308c\u308b\u3001\u3068\u3044\u3046\u5384\u4ecb\u306a\u75c7\u72b6\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>2. \u30c7\u30d7\u30ed\u30a4\u304c\u53cd\u6620\u3055\u308c\u306a\u3044<\/h3>\n<p><code>index.html<\/code> \u306b\u9577\u3044 <code>Cache-Control<\/code> \u3092\u4ed8\u3051\u308b\u3068\u3001\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3082 CloudFront \/ \u30d6\u30e9\u30a6\u30b6\u304c\u53e4\u3044 <code>index.html<\/code> \u3092\u8fd4\u3057\u7d9a\u3051\u307e\u3059\u3002\u9006\u306b\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u7121\u52b9\u306b\u3059\u308b\u3068 CDN \u306e\u610f\u5473\u304c\u8584\u308c\u307e\u3059\u3002<\/p>\n<h3>3. S3 \u3092\u516c\u958b\u3057\u305f\u304f\u306a\u3044<\/h3>\n<p><code>s3:GetObject<\/code> \u3092 <code>Principal: *<\/code> \u3067\u958b\u3051\u3066\u3057\u307e\u3046\u8a18\u4e8b\u3082\u591a\u3044\u3067\u3059\u304c\u3001\u30d0\u30b1\u30c3\u30c8\u3092\u76f4\u63a5\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u6652\u3059\u306e\u306f\u907f\u3051\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002OAC \u3092\u4f7f\u3048\u3070\u975e\u516c\u958b\u306e\u307e\u307e CloudFront \u7d4c\u7531\u306b\u9650\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u539f\u56e0<\/h2>\n<ul>\n<li><strong>404 \u554f\u984c<\/strong>: S3 \u306f\u3042\u304f\u307e\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u3001SPA \u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u77e5\u3089\u306a\u3044\u3002\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u306f\u7d20\u76f4\u306b 404 \u3092\u8fd4\u3059\u3002<\/li>\n<li><strong>\u30ad\u30e3\u30c3\u30b7\u30e5\u554f\u984c<\/strong>: \u30cf\u30c3\u30b7\u30e5\u4ed8\u304d\u30a2\u30bb\u30c3\u30c8\uff08<code>app.a1b2c3.js<\/code>\uff09\u3068 <code>index.html<\/code> \u3092\u540c\u3058\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u3067\u6271\u3063\u3066\u3044\u308b\u305f\u3081\u3002<\/li>\n<li><strong>\u516c\u958b\u554f\u984c<\/strong>: S3 \u306e\u9759\u7684\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u6a5f\u80fd\u3092\u4f7f\u3046\u3068\u3001\u30d0\u30b1\u30c3\u30c8\u3092 public \u306b\u3059\u308b\u5fc5\u8981\u304c\u51fa\u3066\u304f\u308b\u3002OAC \u3092\u4f7f\u3048\u3070\u975e\u516c\u958b\u306e\u307e\u307e CloudFront \u7d4c\u7531\u306b\u9650\u5b9a\u3067\u304d\u308b\u3002<\/li>\n<\/ul>\n<h2>\u5bfe\u5fdc\u65b9\u6cd5<\/h2>\n<p>\u65b9\u91dd\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>S3 \u30d0\u30b1\u30c3\u30c8\u306f <strong>Block Public Access \u3092\u5168\u90e8 ON \u306e\u307e\u307e<\/strong>\u306b\u3059\u308b<\/li>\n<li>CloudFront \u306b <strong>OAC<\/strong> \u3092\u8a2d\u5b9a\u3057\u3001\u30d0\u30b1\u30c3\u30c8\u30dd\u30ea\u30b7\u30fc\u3067\u300c\u3053\u306e Distribution \u304b\u3089\u306e\u307f\u8a31\u53ef\u300d\u3059\u308b<\/li>\n<li>CloudFront \u306e <strong>\u30ab\u30b9\u30bf\u30e0\u30a8\u30e9\u30fc\u30ec\u30b9\u30dd\u30f3\u30b9<\/strong>\u3067\u3001403\/404 \u3092 <code>\/index.html<\/code>\uff08200\uff09\u306b\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u3055\u305b\u308b\uff08SPA \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5bfe\u5fdc\uff09<\/li>\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u306f <strong><code>index.html<\/code> \u306f\u77ed\u547d \/ \u30cf\u30c3\u30b7\u30e5\u4ed8\u304d\u30a2\u30bb\u30c3\u30c8\u306f\u9577\u547d<\/strong> \u306b\u5206\u3051\u308b<\/li>\n<\/ol>\n<h3>\u624b\u9806 1: S3 \u30d0\u30b1\u30c3\u30c8\u4f5c\u6210\u3068\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/h3>\n<pre class=\"lang:default decode:true\"># \u30d0\u30b1\u30c3\u30c8\u4f5c\u6210\uff08\u975e\u516c\u958b\u306e\u307e\u307e\uff09\naws s3 mb s3:\/\/example-spa-bucket --region ap-northeast-1\n\n# Block Public Access \u3092\u660e\u793a\u7684\u306b\u5168 ON\naws s3api put-public-access-block \\\n  --bucket example-spa-bucket \\\n  --public-access-block-configuration \\\n  BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true\n\n# \u30d3\u30eb\u30c9\u6210\u679c\u7269\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\naws s3 sync .\/dist s3:\/\/example-spa-bucket --delete<\/pre>\n<h3>\u624b\u9806 2: OAC \u4ed8\u304d CloudFront \u3092\u4f5c\u308b<\/h3>\n<p>\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u3082\u4f5c\u308c\u307e\u3059\u304c\u3001\u518d\u73fe\u6027\u306e\u305f\u3081 CDK\uff08TypeScript\uff09\u3067\u66f8\u304d\u307e\u3059\u3002\u3053\u3053\u304c\u4e00\u756a\u306e\u30ad\u30e2\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">import * as cdk from \"aws-cdk-lib\";\nimport { Construct } from \"constructs\";\nimport * as s3 from \"aws-cdk-lib\/aws-s3\";\nimport * as cloudfront from \"aws-cdk-lib\/aws-cloudfront\";\nimport * as origins from \"aws-cdk-lib\/aws-cloudfront-origins\";\nimport * as s3deploy from \"aws-cdk-lib\/aws-s3-deployment\";\n\nexport class SpaHostingStack extends cdk.Stack {\n  constructor(scope: Construct, id: string, props?: cdk.StackProps) {\n    super(scope, id, props);\n\n    \/\/ 1. \u975e\u516c\u958b\u306e S3 \u30d0\u30b1\u30c3\u30c8\n    const bucket = new s3.Bucket(this, \"SpaBucket\", {\n      blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,\n      encryption: s3.BucketEncryption.S3_MANAGED,\n      removalPolicy: cdk.RemovalPolicy.RETAIN, \/\/ \u672c\u756a\u306f\u8aa4\u524a\u9664\u9632\u6b62\n    });\n\n    \/\/ 2. CloudFront + OAC\uff08S3BucketOrigin.withOriginAccessControl \u304c\n    \/\/    OAC \u306e\u4f5c\u6210\u3068\u30d0\u30b1\u30c3\u30c8\u30dd\u30ea\u30b7\u30fc\u4ed8\u4e0e\u3092\u81ea\u52d5\u3067\u3084\u3063\u3066\u304f\u308c\u308b\uff09\n    const distribution = new cloudfront.Distribution(this, \"SpaDistribution\", {\n      defaultBehavior: {\n        origin: origins.S3BucketOrigin.withOriginAccessControl(bucket),\n        viewerProtocolPolicy:\n          cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n        cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,\n      },\n      defaultRootObject: \"index.html\",\n\n      \/\/ 3. SPA \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5bfe\u5fdc\uff1a403\/404 \u3092 index.html(200) \u306b\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\n      errorResponses: [\n        {\n          httpStatus: 403,\n          responseHttpStatus: 200,\n          responsePagePath: \"\/index.html\",\n          ttl: cdk.Duration.seconds(0),\n        },\n        {\n          httpStatus: 404,\n          responseHttpStatus: 200,\n          responsePagePath: \"\/index.html\",\n          ttl: cdk.Duration.seconds(0),\n        },\n      ],\n    });\n\n    \/\/ 4. \u30c7\u30d7\u30ed\u30a4\uff1a\u30a2\u30bb\u30c3\u30c8\u306f\u9577\u547d\u30ad\u30e3\u30c3\u30b7\u30e5\u3001index.html \u306f\u5225\u9014\u4e0a\u66f8\u304d\n    new s3deploy.BucketDeployment(this, \"DeploySpa\", {\n      sources: [s3deploy.Source.asset(\".\/dist\")],\n      destinationBucket: bucket,\n      distribution,\n      distributionPaths: [\"\/*\"], \/\/ \u30c7\u30d7\u30ed\u30a4\u6642\u306b\u81ea\u52d5 invalidation\n    });\n\n    new cdk.CfnOutput(this, \"DistributionDomain\", {\n      value: distribution.distributionDomainName,\n    });\n  }\n}<\/pre>\n<p><code>errorResponses<\/code> \u3067 403 \u3082\u62fe\u3063\u3066\u3044\u308b\u306e\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002OAC \u69cb\u6210\u3067\u306f\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u306b\u5bfe\u3057\u3066 S3 \u304c <strong>403<\/strong> \u3092\u8fd4\u3059\u305f\u3081\uff08<code>s3:ListBucket<\/code> \u6a29\u9650\u3092\u6e21\u3057\u3066\u3044\u306a\u3044\u5834\u5408\uff09\u3001404 \u3060\u3051\u62fe\u3046\u3068 SPA \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u304c\u52d5\u304d\u307e\u305b\u3093\u3002<\/p>\n<h3>\u624b\u9806 3: index.html \u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3060\u3051\u77ed\u547d\u306b\u3059\u308b<\/h3>\n<p>CDK \u306e <code>BucketDeployment<\/code> \u3060\u3051\u3060\u3068 <code>index.html<\/code> \u3082\u542b\u3081\u3066\u4e00\u5f8b\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u306a\u308b\u306e\u3067\u3001CI \u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4e0a\u66f8\u304d\u3059\u308b\u306e\u304c\u5b9f\u52d9\u7684\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\"># \u30cf\u30c3\u30b7\u30e5\u4ed8\u304d\u30a2\u30bb\u30c3\u30c8\u306f\u9577\u547d\uff08immutable\uff09\naws s3 sync .\/dist s3:\/\/example-spa-bucket \\\n  --exclude \"index.html\" \\\n  --cache-control \"public, max-age=31536000, immutable\"\n\n# index.html \u306f\u5e38\u306b\u53d6\u308a\u76f4\u3055\u305b\u308b\naws s3 cp .\/dist\/index.html s3:\/\/example-spa-bucket\/index.html \\\n  --cache-control \"no-cache, no-store, must-revalidate\"\n\n# index.html \u3060\u3051 invalidation\uff08\u30b3\u30b9\u30c8\u6700\u5c0f\uff09\naws cloudfront create-invalidation \\\n  --distribution-id XXXXXXXXXXXX \\\n  --paths \"\/index.html\"<\/pre>\n<p><code>app.a1b2c3.js<\/code> \u306e\u3088\u3046\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u30cf\u30c3\u30b7\u30e5\u304c\u5165\u3063\u3066\u3044\u308c\u3070\u3001\u5185\u5bb9\u304c\u5909\u308f\u308c\u3070 URL \u3082\u5909\u308f\u308b\u305f\u3081\u9577\u547d\u30ad\u30e3\u30c3\u30b7\u30e5\u3067\u5b89\u5168\u3067\u3059\u3002<code>index.html<\/code> \u3060\u3051\u6bce\u56de\u53d6\u308a\u76f4\u305b\u3070\u3001\u65b0\u3057\u3044\u30a2\u30bb\u30c3\u30c8\u3078\u306e\u53c2\u7167\u304c\u78ba\u5b9f\u306b\u914d\u3089\u308c\u307e\u3059\u3002<\/p>\n<h3>\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u4ed8\u3051\u308b\u5834\u5408<\/h3>\n<p>\u72ec\u81ea\u30c9\u30e1\u30a4\u30f3 + HTTPS \u306b\u3059\u308b\u306a\u3089 ACM \u8a3c\u660e\u66f8\u304c\u5fc5\u8981\u3067\u3059\u3002<strong>CloudFront \u304c\u53c2\u7167\u3059\u308b\u8a3c\u660e\u66f8\u306f <code>us-east-1<\/code>\uff08\u30d0\u30fc\u30b8\u30cb\u30a2\u5317\u90e8\uff09\u3067\u767a\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b<\/strong>\u70b9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6771\u4eac\u30ea\u30fc\u30b8\u30e7\u30f3\u3067\u4f5c\u308b\u3068 CloudFront \u306b\u7d10\u4ed8\u3051\u3089\u308c\u307e\u305b\u3093\u3002<\/p>\n<h2>\u78ba\u8a8d\u65b9\u6cd5<\/h2>\n<p>\u30c7\u30d7\u30ed\u30a4\u5f8c\u3001\u6b21\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\"># 1. \u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304c 200 \u3067\u8fd4\u308b\u304b\ncurl -I https:\/\/xxxxxxxxxxxxx.cloudfront.net\/\n\n# 2. \u6df1\u3044\u30d1\u30b9\u3092\u76f4\u63a5\u53e9\u3044\u3066\u30ea\u30ed\u30fc\u30c9\u76f8\u5f53\u3092\u518d\u73fe\uff08200 + index.html \u304c\u8fd4\u308c\u3070\u6210\u529f\uff09\ncurl -sI https:\/\/xxxxxxxxxxxxx.cloudfront.net\/users\/123 | head -n 1\n# \u2192 HTTP\/2 200\n\n# 3. S3 \u3092\u76f4\u63a5\u53e9\u3044\u3066 403 \u306b\u306a\u308b\uff08\uff1d\u516c\u958b\u3055\u308c\u3066\u3044\u306a\u3044\uff09\u3053\u3068\u3092\u78ba\u8a8d\ncurl -I https:\/\/example-spa-bucket.s3.ap-northeast-1.amazonaws.com\/index.html\n# \u2192 403 Forbidden \u306a\u3089 OK\uff08CloudFront \u7d4c\u7531\u306e\u307f\u30a2\u30af\u30bb\u30b9\u53ef\uff09\n\n# 4. \u30ad\u30e3\u30c3\u30b7\u30e5\u30d8\u30c3\u30c0\u306e\u78ba\u8a8d\ncurl -sI https:\/\/xxxxxxxxxxxxx.cloudfront.net\/index.html | grep -i cache-control\ncurl -sI https:\/\/xxxxxxxxxxxxx.cloudfront.net\/assets\/app.a1b2c3.js | grep -i cache-control<\/pre>\n<p>\u5224\u5b9a\u57fa\u6e96:<\/p>\n<ul>\n<li>\u6df1\u3044\u30d1\u30b9\u304c 200 \u3067 <code>index.html<\/code> \u306e\u5185\u5bb9\u304c\u8fd4\u308c\u3070 SPA \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u6210\u529f<\/li>\n<li>S3 \u76f4\u30a2\u30af\u30bb\u30b9\u304c 403 \u306a\u3089\u975e\u516c\u958b\u304c\u62c5\u4fdd\u3055\u308c\u3066\u3044\u308b<\/li>\n<li><code>index.html<\/code> \u306f <code>no-cache<\/code>\u3001\u30a2\u30bb\u30c3\u30c8\u306f <code>max-age=31536000<\/code> \u306b\u306a\u3063\u3066\u3044\u308c\u3070 OK<\/li>\n<\/ul>\n<h2>\u6ce8\u610f\u70b9<\/h2>\n<ul>\n<li><strong>OAC \u3068 OAI \u3092\u6df7\u540c\u3057\u306a\u3044<\/strong>: OAI\uff08Origin Access Identity\uff09\u306f\u65e7\u65b9\u5f0f\u3002\u65b0\u898f\u69cb\u7bc9\u306f OAC \u3092\u4f7f\u3046\u3002SSE-KMS \u6697\u53f7\u5316\u3068\u306e\u76f8\u6027\u3082 OAC \u306e\u65b9\u304c\u826f\u3044\u3002<\/li>\n<li><strong>403 \u3082 SPA \u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u5bfe\u8c61\u306b\u5165\u308c\u308b<\/strong>: OAC \u69cb\u6210\u3067\u306f 404 \u3067\u306a\u304f 403 \u304c\u8fd4\u308b\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3002\u4e21\u65b9 <code>errorResponses<\/code> \u306b\u5165\u308c\u308b\u3002<\/li>\n<li><strong>\u30a8\u30e9\u30fc\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u526f\u4f5c\u7528<\/strong>: 403\/404 \u3092\u4e00\u5f8b 200 \u306e <code>index.html<\/code> \u306b\u3059\u308b\u3068\u3001\u672c\u6765 404 \u3067\u3042\u308b\u3079\u304d API \u7684\u306a\u6271\u3044\u3082\u30c8\u30c3\u30d7\u306b\u843d\u3061\u308b\u3002API \u306f\u5225\u30aa\u30ea\u30b8\u30f3 \/ \u5225 Behavior \u306b\u5206\u96e2\u3059\u308b\u3002<\/li>\n<li><strong>invalidation \u306f\u30b3\u30b9\u30c8\u306b\u6ce8\u610f<\/strong>: <code>\/*<\/code> \u306e invalidation \u306f\u6708 1000 \u30d1\u30b9\u307e\u3067\u7121\u6599\u3060\u304c\u3001\u6bce\u30c7\u30d7\u30ed\u30a4\u3067\u591a\u7528\u3059\u308b\u3068\u8ab2\u91d1\u5bfe\u8c61\u306b\u306a\u308b\u3002\u30cf\u30c3\u30b7\u30e5\u4ed8\u304d\u30a2\u30bb\u30c3\u30c8\u904b\u7528\u306b\u3057\u3066 <code>index.html<\/code> \u3060\u3051 invalidate \u3059\u308b\u306e\u304c\u5b89\u4e0a\u304c\u308a\u3002<\/li>\n<li><strong>\u8a3c\u660e\u66f8\u306f <code>us-east-1<\/code><\/strong>: \u3053\u308c\u306f\u4ed5\u69d8\u3002\u5fd8\u308c\u308b\u3068\u8a70\u307e\u308b\u3002<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081<\/h2>\n<ul>\n<li>S3 \u306f <strong>\u975e\u516c\u958b\u306e\u307e\u307e<\/strong>\u3001OAC \u3067 CloudFront \u304b\u3089\u306e\u307f\u8aad\u307e\u305b\u308b<\/li>\n<li>SPA \u306e\u30ea\u30ed\u30fc\u30c9 404 \u306f <strong>403\/404 \u2192 <code>\/index.html<\/code>(200)<\/strong> \u306e\u30ab\u30b9\u30bf\u30e0\u30a8\u30e9\u30fc\u30ec\u30b9\u30dd\u30f3\u30b9\u3067\u89e3\u6c7a<\/li>\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u306f <strong><code>index.html<\/code> \u77ed\u547d \/ \u30cf\u30c3\u30b7\u30e5\u4ed8\u304d\u30a2\u30bb\u30c3\u30c8\u9577\u547d<\/strong> \u3067\u5206\u3051\u308b<\/li>\n<li>\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u306e\u8a3c\u660e\u66f8\u306f <strong><code>us-east-1<\/code><\/strong> \u3067\u767a\u884c<\/li>\n<\/ul>\n<p>\u3053\u306e 4 \u70b9\u3092\u62bc\u3055\u3048\u308c\u3070\u3001\u5b89\u5168\u3067\u53cd\u6620\u306e\u901f\u3044 SPA \u914d\u4fe1\u57fa\u76e4\u304c\u4f5c\u308c\u307e\u3059\u3002CDK \u306b\u3057\u3066\u304a\u304f\u3068\u74b0\u5883\u306e\u518d\u73fe\u3068\u30ec\u30d3\u30e5\u30fc\u304c\u697d\u306b\u306a\u308b\u306e\u3067\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u624b\u4f5c\u696d\u3088\u308a\u6700\u521d\u304b\u3089 IaC \u5316\u3059\u308b\u306e\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React \/ Vue \u306a\u3069\u306e SPA\uff08Single Page Application\uff09\u3092\u672c\u756a\u914d\u4fe1\u3059\u308b\u5b9a\u756a\u69cb\u6210\u304c\u300cS3 \u306b\u30d3\u30eb\u30c9\u6210\u679c\u7269\u3092\u7f6e\u304d\u3001CloudFront \u304b\u3089\u914d\u4fe1\u3059\u308b\u300d\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002\u624b\u9806\u81ea\u4f53\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u304c\u3001\u7d20\u76f4\u306b\u4f5c\u308b\u3068\u6b21\u306e\u3088\u3046\u306a\u2026<\/p>\n","protected":false},"author":1,"featured_media":3626,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_lightning_design_setting":[],"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[75],"tags":[64,499,1199,967],"class_list":["post-3627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-of-serverside","tag-api","tag-aws","tag-s3","tag-spa"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2026\/10\/20260914-00mu0ksb-thumbnail.jpg","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=3627"}],"version-history":[{"count":1,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3627\/revisions"}],"predecessor-version":[{"id":3628,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3627\/revisions\/3628"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/3626"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=3627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=3627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=3627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}