APC 适合高度动态的 PHP 网站吗?
对于某些人来说这可能是一个微不足道的问题,但我自己还找不到答案。
如果我理解正确的话,APC 会做两件事。将 PHP 页面保留为字节代码,以便更快地交付它们。它还可以缓存数据,以便我们可以更快地查询它们。
我对字节码功能感兴趣,如果我理解正确的话,它是默认的。我不需要对我的代码进行太多修改即可使其工作。
我的问题是:我们的网站是一个社交网站,我们的 PHP 页面是高度动态的。他们每次被召唤都会受到很多因素的影响。
我们仍然会从使用 APC 中受益吗?
谢谢, 哈鲁克
This might be a trivial question for some, but I could not find the answer myself yet.
If I understand correctly APC does two things. Keep the PHP pages in byte code so they are delivered faster. It can also cache data so we can query them faster.
I'm interested in the byte code feature, which if I understand correctly comes by default. I will not need to modify my code much for this to work.
My question is this: Our website is a social network site and our PHP pages are highly dynamic. They are affected by many factors every time they are called.
Would we still benefit from using APC?
Thanks,
Haluk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这正是 APC 非常适合的情况(尽管它对所有类型的页面都有好处)。它本质上是 PHP 代码的“编译器”。
除非背后的 PHP 代码的更改频率比页面加载的频率更高(我认为这种情况永远不会发生),否则 APC 将使您受益。
对于任何静态页面(或页面的静态部分),您可能需要考虑将输出缓存到系统上的文件中。这样,当您需要显示该组件时,您可以只提供缓存的 HTML,而不是运行 PHP 代码。
Yes that is exactly the type of situation that APC works great in (although it benefits all types of pages). It's essentially a "compiler" for PHP code.
Unless the PHP code behind is changing more often than the page is loaded (I don't think that would EVER happen), APC will benefit you.
For any static pages (or static parts of pages), you might want to look into caching the output to files on the system. That way, when you need to display that component, instead of running PHP code you can just serve up the cached HTML.
它对于网站的动态部分效果不太好,除非您单独缓存它们,但您将受益于字节码缓存,而无需对代码进行任何更改
进一步阅读
It wont work so well for the dynamic parts of your website, unless you cache them individually, but you will benefit from the bytecode cache without any changes to your code
Further reading