Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Slim's route cache file
May 31, 2017 @ 14:35:15

In a new post to his site Rob Allen talks about how you can speed up the routing in your Slim framework based application using the route cache file.

When you have a lot of routes, that have parameters, consider using the router's cache file to speed up performance.

To do this, you set the routerCacheFile setting to a valid file name. The next time the app is run, then the file is created which contains an associative array with data that means that the router doesn't need to recompile the regular expressions that it uses.

He gives an example of how to enable the setting and makes the recommendation that it's only used in production. He includes a simple example that defines "25 groups, each with 4000 routes, each of which has a placeholder parameter with a constraint." The first run on a route responds in 2.7 seconds but, once the cache file is created, it drops down to just 263 milliseconds - a major improvement.

tagged: slim route cache file tutorial example performance

Link: https://akrabat.com/slims-route-cache-file/


Trending Topics: