Skip to content

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed May 18, 2024
1 parent 657aefb commit efb70f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
11 changes: 2 additions & 9 deletions packages/sst/src/constructs/NextjsSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
}

const DEFAULT_OPEN_NEXT_VERSION = "3.0.1";
const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = ["x-open-next-cache-key"];

type NextjsSiteNormalizedProps = NextjsSiteProps & SsrSiteNormalizedProps;

Expand Down Expand Up @@ -246,12 +245,6 @@ export class NextjsSite extends SsrSite {
}
}

public static override buildDefaultServerCachePolicyProps(): CachePolicyProps {
return super.buildDefaultServerCachePolicyProps(
DEFAULT_CACHE_POLICY_ALLOWED_HEADERS
);
}

private createFunctionOrigin(
fn: OpenNextFunctionOrigin,
key: string,
Expand Down Expand Up @@ -429,8 +422,8 @@ export class NextjsSite extends SsrSite {
}
: undefined,
serverCachePolicy: {
allowedHeaders: DEFAULT_CACHE_POLICY_ALLOWED_HEADERS,
}
allowedHeaders: ["x-open-next-cache-key"],
},
});
}

Expand Down
38 changes: 14 additions & 24 deletions packages/sst/src/constructs/SsrSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1260,11 +1260,20 @@ function handler(event) {
const allowedHeaders = plan.serverCachePolicy?.allowedHeaders ?? [];
singletonCachePolicy =
singletonCachePolicy ??
new CachePolicy(
self,
"ServerCache",
SsrSite.buildDefaultServerCachePolicyProps(allowedHeaders)
);
new CachePolicy(self, "ServerCache", {
queryStringBehavior: CacheQueryStringBehavior.all(),
headerBehavior:
allowedHeaders.length > 0
? CacheHeaderBehavior.allowList(...allowedHeaders)
: CacheHeaderBehavior.none(),
cookieBehavior: CacheCookieBehavior.none(),
defaultTtl: CdkDuration.days(0),
maxTtl: CdkDuration.days(365),
minTtl: CdkDuration.days(0),
enableAcceptEncodingBrotli: true,
enableAcceptEncodingGzip: true,
comment: "SST server response cache policy",
});
return singletonCachePolicy;
}

Expand Down Expand Up @@ -1456,25 +1465,6 @@ function handler(event) {
}
}

protected static buildDefaultServerCachePolicyProps(
allowedHeaders: string[]
): CachePolicyProps {
return {
queryStringBehavior: CacheQueryStringBehavior.all(),
headerBehavior:
allowedHeaders.length > 0
? CacheHeaderBehavior.allowList(...allowedHeaders)
: CacheHeaderBehavior.none(),
cookieBehavior: CacheCookieBehavior.none(),
defaultTtl: CdkDuration.days(0),
maxTtl: CdkDuration.days(365),
minTtl: CdkDuration.days(0),
enableAcceptEncodingBrotli: true,
enableAcceptEncodingGzip: true,
comment: "SST server response cache policy",
};
}

/**
* The CloudFront URL of the website.
*/
Expand Down

0 comments on commit efb70f7

Please sign in to comment.