I’m using a traditional Zend framework application generated using Zend tool. I have several modules in my application all generated using Zend tool too. I’m intending to use the default routes in Zend framework in my application.
For example: www.host.com/module/controller/action/param1/value1/param2/value2
Here are my questions:
- Performance wise, using the default routes is the fastest solution, right?
- 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? - What is the pros of making custom routes? is it better for SEO?
- 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)
Note:
I understand the routing process itself and how it works in Zend
framework. However, since I won’t be using most of the features
available I thought maybe it’s time for fine tuning 🙂
Thanks in advance.
Right, but not using any routing system is the fastest solution (obviously).
Well, that’s the thing, routes are mostly used for flexibility, internationalization, SEO.
The problem with the Zend Framework Router is that it depends and wraps the Front Controller instance, therefore it is hard (well impossible afaik) to cache the Router since the FC itself wraps others things like PDO instances which are not cachable.
So all routes are computed again and again for every requests.
A possible solution when using complex routes while avoiding route computation is to dump all routes to native Apache Rewrite Rules, it will be blazing fast compared to ZF, the main problem with this solution is that you need to manually compute reverse routes and whenever you make a change to a route, you’ll need to edit it by hand.
As often, it is scalability vs performance.
Well, it “depends” ™:
/list?type=productsvs/products, the second route wins.However,
/products/page/1vs/products?page=1is a win-win (well it actually does not but it is another story).Other pros:
I don’t see any cons against this. I often go for it, except for RESTfull API.