Question:
I have my web application implemented using Angular Universal Starter kit. I want to upload the pre-rendered file to the S3 bucket so that my initial page gets loaded faster.But I couldn’t find the proper configurations regarding uploading the pre-rendered file to S3 and how to access that file on initial load?
Answer:
Using a prerendered HTML is the same as uploading a static website. Assuming that you have aws cli installed and configured (using aws configure
), you can run the following command on the directory to upload the file to a s3 bucket.
This will only upload/update those files which have changed from the
existing bucket files.
1 2 |
aws s3 sync my_local_dir s3://my_s3_bucket_name |
Additionally, if you want to set cache then you can add the following option
1 2 |
aws s3 sync my_local_dir s3://my_s3_bucket_name --cache-control max-age=604800 |