laravel-bridge icon indicating copy to clipboard operation
laravel-bridge copied to clipboard

Add route caching

Open kolos opened this issue 3 months ago • 5 comments

Use route cache automatically the same way as the config cached.

It saves ~3ms on every request for me.

kolos avatar Sep 02 '25 14:09 kolos

Running 'php artisan route:cache' adds about 300ms to the cold start (tested on x64 / 1024M)

kolos avatar Sep 08 '25 16:09 kolos

Status update: want to test this myself in a real project too, +300ms to the cold start is not negligible, even to get -3ms on warm invokes.

The alternative for people interested in optimizing performance is to cache routes before deploying (https://mnapoli.fr/optimizing-laravel-aws-lambda), which maybe makes more sense here.

mnapoli avatar Sep 12 '25 08:09 mnapoli

Shouldn't the route caching happen as part of the build process?

tillkruss avatar Sep 12 '25 13:09 tillkruss

Yes exactly my point

mnapoli avatar Sep 12 '25 16:09 mnapoli

Well, if you know that you should (and can) run route:cache before deploying, it has no effect for you. Otherwise, it’s done automatically, with the benefit of faster responses.

I agree that it should be part of the build process, I do it now too :)

kolos avatar Sep 12 '25 17:09 kolos