Any tips for making API calls faster?

I made my API calls as viewless handlers that behave very nicely within ColdBox. They call a service, the service calls a gateway, and everything fits the framework and behaves.

But this takes one or two seconds longer than an API function that doesn’t use a framework.

One or two seconds for each API call makes the application seem slower.

Any tips for making my API calls faster? Would you just handle API calls outside of ColdBox?

In ColdBox config file, there are settings to cache handlers, events, and views.

handlerCaching = true,
eventCaching = true,
viewCaching = true,

You might try that; and see if that could make API calls faster.

Ref: ColdBox - ColdBox HMVC Documentation

There is also settings for modules.

Ref: Modules - ColdBox HMVC Documentation

There’s no way Coldbox is adding 1 to 2 seconds to your calls. I can hit a generic ColdBox page and it runs in about 5 ms on my machine. That’s 5 milliseconds! I would recommend using FusionReactor’s profiler feature to find out exactly what bits of your app are taking time. You can configure the FR profile to kick in for all request (it only kicks in after 8 seconds by default). If if you don’t have ColdBox production settings, it wouldn’t take 2 seconds. I just tested reinitting a ColdBox site (which involves a full tear down and re-creation of the framework) and it runs in 115 ms.

I think we figured it out. We had event caching on. We turned it off and now it’s faster. Thanks!

If anything, event caching should speed up your site, not slow it down. What cache provider are you using? It’s possible there is an issue if you have an external cache configured where the actual calls to the caching engine are running very slow due to network or something. Again, FusionReactor will show you exactly what is going on. Don’t guess; know.