【问题标题】:Deploy ReactJS Application in AWS Cloud Front在 AWS Cloudfront 中部署 React JS 应用程序
【发布时间】:2019-01-30 10:17:27
【问题描述】:

我有一些关于在云端部署 React 应用程序的问题。

Cloud Front 上托管的前端网站的缓存和更新是如何工作的?

When I upload a new files to the bucket I will see the changes IMEDIATELY after accessing the site again? If not, how long it will take?
I need to make an invalidate request to see the changes working on the website? If yes, how long it will take?

在 Cloud Front 中处理单页应用程序的缓存和更新的最佳方法是什么? (我正在使用 React 应用程序和 Webpack)

【问题讨论】:

    标签: reactjs amazon-s3 react-redux amazon-cloudfront


    【解决方案1】:

    您需要做的是清除存储桶的缓存或“使”文件“无效”。

    https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

    所以安装 aws cli 并运行以下命令:

    aws cloudfront create-invalidation --distribution-id $CDN_DISTRIBUTION_ID --paths "/*"

    我建议您使用 S3 存储桶进行开发。

    【讨论】:

    • 谢谢塞尔吉奥!我读到了关于失效的信息,这正是我的想法。但我的问题是:刷新/重新进入网站时,更改需要多长时间才能生效?
    • 当您使云端缓存失效时,通常需要大约 5 分钟。也可以少一些。取决于您尝试失效的资源。
    猜你喜欢
    • 2014-09-18
    • 2017-02-08
    • 2018-05-15
    • 2018-07-07
    • 2018-08-23
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    • 2020-08-26
    相关资源
    最近更新 更多