Skip to content

Commit

Permalink
5分はキャッシュする
Browse files Browse the repository at this point in the history
  • Loading branch information
takecchi committed Dec 19, 2023
1 parent e4b55ce commit 02ef9e7
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions sst.config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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: {
Expand All @@ -44,9 +35,9 @@ export default {
},
warm: 100,
logging: 'combined',
// cdk: {
// serverCachePolicy,
// },
cdk: {
serverCachePolicy,
},
});

stack.addOutputs({
Expand Down

0 comments on commit 02ef9e7

Please sign in to comment.