php - 优化Zend框架路由

标签 php zend-framework optimization routes zend-route

我正在使用使用 Zend 工具 生成的传统 Zend 框架应用程序。我的应用程序中有几个模块也都是使用 Zend 工具生成的。我打算在我的应用程序中使用 Zend 框架中的默认路由

例如:www.host.com/module/controller/action/param1/value1/param2/value2

这是我的问题:

  1. 就性能而言,使用默认路由是最快的解决方案,对吗?
  2. 既然我永远不会改变路线,有没有办法让 路由过程更快?例如缓存?跳过路由 完全处理?或者任何其他技术?
  3. 制作自定义路线的优点是什么?对 SEO 更好吗?
  4. 我可以跳过 AJAX 调用的路由过程吗? (我知道答案 大部分是“否”,但也许我可以进一步优化我的 AJAX 调用)

注意:

我了解路由过程本身以及它在 Zend 中的工作原理 框架。但是,由于我不会使用大部分功能 可用我想也许是时候进行微调了:)

提前致谢。

最佳答案

1 . Performance wise, using the default routes is the fastest solution, right?

是的,但不使用任何路由系统是最快的解决方案(显然)。

2 . Since I won't ever change the routes, is there a way to make the routing process even faster? caching for example? skipping the routing process entirely? or any other technique?

嗯,就是这样,路由主要用于灵活性、国际化、SEO。

Zend Framework Router 的问题在于它依赖并包装 Front Controller 实例,因此很难(据我所知不可能)缓存 Router,因为 FC 本身包装了其他不可缓存的东西,例如 PDO 实例。

因此,对于每个请求,所有路由都会一次又一次地计算。

当使用复杂路由同时避免路由计算时,一个可能的解决方案是将所有路由转储到 native Apache Rewrite Rules,与 ZF 相比,它会非常快,该解决方案的主要问题是您需要手动计算反向路由并每当您更改路线时,您都需要手动编辑它。

通常,这是可扩展性与性能

3 . What is the pros of making custom routes? is it better for SEO?

嗯,这“取决于”(tm):

/list?type=products/products 相比,第二条路线获胜。

但是,/products/page/1/products?page=1 是双赢的(实际上不是,但这是另一个故事)。

其他优点:

  • 国际化
  • 搜索引擎优化
  • 可用性
  • 有意义的网址

4 . Can I skip the routing process for AJAX calls? (I know the answer is mostly NO, but maybe I can optimize my call further for AJAX calls)

我认为这没有任何缺点。我经常使用它,除了 RESTfull API。

关于php - 优化Zend框架路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10070634/

相关文章:

php下拉菜单人口

php - android从android接收数据到web时出错

windows - Zend : . htaccess 现在不能在 Windows 上运行如何继续我的项目?

php - Zend_Framework- 在哪里放置 $_GET 和 $_POST(HTTP 请求)处理?

c++ - C++ 编译器可以优化对 at() 的调用吗?

c# - 优化 C# 文件 IO

php - PHP 从 5.3.1 升级到 5.3.2 后 session 不起作用

php - 如何在临近到期时间时向用户发送通知(每年)

php - htaccess 阻止访问目录但允许访问文件

optimization - 调整 MIT 的 bitcount 算法以并行计算单词?