Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

feat: use cloudfront as cdn #30

Merged
merged 20 commits into from
Aug 3, 2020
Merged

feat: use cloudfront as cdn #30

merged 20 commits into from
Aug 3, 2020

Conversation

jiegec
Copy link
Member

@jiegec jiegec commented Jul 27, 2020

To fix #9

  • use cloudfront as CDN to distribute entire site, use the ALB as origin
  • different cache policies for different content
  • support custom domain and SSL certificate(NOTE: ACM certificate not supported used by CloudFront in China regions, use IAM cert as workaround) via context parameters
  • update domain records in r53
  • unit tests
  • update readme

Will do later:

  • custom cloudfront invalidation for web portal

@zxkane
Copy link
Collaborator

zxkane commented Jul 29, 2020

Let's update cdk to 1.55.0 to pick up feature and bug fixes for cloudfront.

https://github.com/aws/aws-cdk/releases/tag/v1.55.0

@jiegec
Copy link
Member Author

jiegec commented Jul 30, 2020

What cache policies is needed:

  1. Content server and web portal can have a larger cache time
  2. /static/tunasync.json should have a small cache time or none

When custom invalidation is needed:

  1. index files (like InRelease of debian, ubuntu etc) can be invalidated as soon as they are changed

@zxkane
Copy link
Collaborator

zxkane commented Jul 31, 2020

I propose below cache policy,

  • default 1 day cache for the alb origin
  • override cache policy via upstream http headers
    • yum/debian repos
      • short cache time for package database files, such as 30/60m,
      • long cache time for binary files, such as 1y
    • short cache time for tunasync.json, such as 5/10m
    • other repos using default policy of cloudfront, let's polish their policies in future
  • invalidate the web portal after new deployment via custom resource
    • use image hash as custom property
    • specify the paths of web server to be invalidated

What cache policies is needed:

  1. Content server and web portal can have a larger cache time
  2. /static/tunasync.json should have a small cache time or none

When custom invalidation is needed:

  1. index files (like InRelease of debian, ubuntu etc) can be invalidated as soon as they are changed

@zxkane
Copy link
Collaborator

zxkane commented Aug 1, 2020

CDK v1.56.0 is introduced lots of cloudfront changes. Let's adopt it.

https://github.com/aws/aws-cdk/releases/tag/v1.56.0

@jiegec jiegec requested a review from zxkane August 1, 2020 14:52
lib/opentuna-stack.ts Outdated Show resolved Hide resolved
lib/opentuna-stack.ts Show resolved Hide resolved
@zxkane zxkane changed the title feat: use cloudfront as cdn WIP: feat: use cloudfront as cdn Aug 2, 2020
@zxkane zxkane changed the title WIP: feat: use cloudfront as cdn feat: use cloudfront as cdn Aug 3, 2020
@zxkane zxkane self-requested a review August 3, 2020 08:24
@zxkane
Copy link
Collaborator

zxkane commented Aug 3, 2020

@jiegec let me know if you have any comment for new commits.

@jiegec jiegec merged commit 5af1ab3 into master Aug 3, 2020
@jiegec jiegec deleted the cloudfront-cdn branch August 3, 2020 09:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use cdn to distribute the content of repo
2 participants