Skip to content

Conversation

@kolos
Copy link

@kolos kolos commented Sep 2, 2025

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

It saves ~3ms on every request for me.

Copy link
Member

@mnapoli mnapoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks that sounds good to me, any idea how much time it adds to cold starts?

@kolos
Copy link
Author

kolos commented Sep 8, 2025

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

@mnapoli
Copy link
Member

mnapoli commented Sep 12, 2025

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.

@tillkruss
Copy link
Member

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

@mnapoli
Copy link
Member

mnapoli commented Sep 12, 2025

Yes exactly my point

@kolos
Copy link
Author

kolos commented Sep 12, 2025

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants