如何提高 CakePHP 应用程序的性能?
我目前在我的训练计划应用程序中使用 CakePHP,但每页的渲染时间为 800 毫秒。
您对提高性能有什么建议吗?
提前致谢。
br、公里
I'm currently using CakePHP for my training plan application but I have rendering times of 800 ms per page.
Do you have any tips on improving the performance?
Thanks in advance.
br, kms
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一般来说,能给你带来最大速度提升的工具是缓存,CakePHP 有一个专用的帮助器。第二个最有用的事情是优化查询,只询问您需要的数据 - 这可以通过 可控制的行为。
您可以在这篇文章中找到更多详细提示。
In general the tool that will give you the greatest speed boost is caching, and CakePHP has a dedicated helper. The second most useful thing to do is optimizing the queries, only asking for the data you need - this can be done with the containable behavior.
You can find more detailed tips in this post.
如果没有 APC,请安装它。这将立即使它< 500 毫秒。也无需触及任何一行代码。
确保您的表具有所有正确的索引,以便查询尽可能快。
接下来看看有关缓存路由/ URL 的一些事情,因为这是一个巨大的消耗。
这些将为您提供最少工作量的最大速度提升
Install APC, if you dont have it. that will instantly make it < 500ms. also without touching a single line of code.
Make sure your tables have all the proper indexes so that queries are as fast as they can be.
Next up look at some things about caching routes / urls as that is a huge drain.
Those will give you the most speed boost for the least amount of work
您是否尝试过 CakePHP 的 CSS/JS 资源组合器?它们组合/压缩/缩小您的 CSS/JS 脚本并在适用的情况下缓存它们。 这里是一个是最近的。
并非特定于 CakePHP,但您可以查看 Google Page Speed 中的所有因素,它将通过建议您可以组合哪些脚本以及如何减少请求的建议来帮助您加快页面加载时间。
除此之外,研究一下可控制的行为,看看是否可以通过随时选择您需要的内容来删除任何必要的信息/查询。
Have you tried any of the CSS/JS asset combiners for CakePHP? They combine/compress/minify your CSS/JS scripts and cache them where applicable. Here's one that's quite recent.
Not specific to CakePHP but you could go through all the factors in Google Page Speed, it will help you speed up your page loading times by suggesting what scripts you could combine and advice on how to reduce requests.
Other than that, look into the containable behaviour, see if you can cut out any necessary info/queries by only selecting what you need at any time.
这个问题充满了有关加速 Cake up 的信息。
This question is well-populated with information on speeding Cake up.