From 02ef9e76b630e2ccc4f4e831aa7c020896c563a5 Mon Sep 17 00:00:00 2001 From: takecchi Date: Tue, 19 Dec 2023 22:17:29 +0900 Subject: [PATCH] =?UTF-8?q?5=E5=88=86=E3=81=AF=E3=82=AD=E3=83=A3=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sst.config.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/sst.config.ts b/sst.config.ts index 38c88897d..e62dc004f 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -1,6 +1,6 @@ import { SSTConfig } from 'sst'; import { NextjsSite } from 'sst/constructs'; -import { CacheHeaderBehavior, CachePolicy } from 'aws-cdk-lib/aws-cloudfront'; +import { CachePolicy } from 'aws-cdk-lib/aws-cloudfront'; import { Duration } from 'aws-cdk-lib'; export default { @@ -18,18 +18,9 @@ export default { domain = `${stack.stage}.${domain}`; } // CloudFrontでキャッシュさせたい場合に使用すること - const _serverCachePolicy = new CachePolicy(stack, 'ServerCache', { - minTtl: Duration.seconds(86400), - defaultTtl: Duration.seconds(86400), - headerBehavior: CacheHeaderBehavior.allowList( - 'accept', - 'rsc', - 'next-router-prefetch', - 'next-router-state-tree', - 'next-url', - ), - enableAcceptEncodingGzip: true, - enableAcceptEncodingBrotli: true, + const serverCachePolicy = new CachePolicy(stack, 'ServerCache', { + ...NextjsSite.buildDefaultServerCachePolicyProps(), + defaultTtl: Duration.seconds(300), }); const site = new NextjsSite(stack, 'site', { customDomain: { @@ -44,9 +35,9 @@ export default { }, warm: 100, logging: 'combined', - // cdk: { - // serverCachePolicy, - // }, + cdk: { + serverCachePolicy, + }, }); stack.addOutputs({