Dam*_*tto 6 performance amazon-web-services server-side-rendering next.js aws-amplify
我在 AWS Amplify 上的 Nextjs SSR 应用程序太慢:
本地电脑上的同一个应用程序以命令启动yarn build&&yarn start它足够快,但在 aws 上:
不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: {},
};
}
}
Run Code Online (Sandbox Code Playgroud)
第一次点击页面后,同一页面(带有其他参数)速度更快(~2.1秒)...我尝试启用“放大性能模式”,它应该延长缓存时间,但没有真正的改进。我该如何解决这个问题?
[更新] 今天我意识到进入 amplify 后,有人向我提出了“使用 nextjs 12 进行改进和性能”的更新。
我这样做了,它实际上变得更快了......不过它弄乱了我的后端环境......
AWS 使用 NextJS 12 增强性能提升 - 意外的后端环境切换
| 归档时间: |
|
| 查看次数: |
673 次 |
| 最近记录: |