NextJS SSR AWS Amplify -生产环境加载缓慢

cgvd09ve  于 2023-06-22  发布在  其他
关注(0)|答案(1)|浏览(161)

我在AWS Amplify上的Nextjs SSR应用程序太慢:
本地PC上的同一个应用程序启动命令yarn build && yarn start,速度足够快,但在AWS上:

  • 首页加载:10.43秒
  • 当点击页面中的链接时:9.5秒

getServerSideProps()不调用999 API,只是从cognito检索用户数据:

export async function getServerSideProps(context) {
  let req = context.req;
  const { Auth } = withSSRContext({ req });
  try {
    let user = await Auth.currentAuthenticatedUser();
    return {
      props: {
        param1: context.params.param1,
        param2: context.params.param2,
        user: user,
        ...(await serverSideTranslations(context.locale, ["common", "dashboard", "footer","fs"])),
      },
    };
  } catch (err) {
    return {
      redirect: {
        permanent: false,
        destination: "/auth/signin",
      },
      props: {},
    };
  }
}

第一次点击页面后,同一页面(与其他参数)它的速度更快(~2.1秒)...我试着启用“放大性能模式”,它应该延长缓存的时间,但没有真实的的改善。我该怎么办?

ugmeyewa

ugmeyewa1#

[更新]今天我意识到,进入amplify,一个更新向我提出了“使用nextjs 12的改进和性能”。
我就这么做了,而且速度真的快多了...它破坏了我的后台环境...
AWS通过NextJS 12增强性能提升-意外后端环境切换

相关问题