The benefits of caching in CI

And it's not for performance reasons

Joel Clermont
Joel Clermont
2023-12-27

Yesterday, I talked about why caching in your local environment is a bad idea, but today I'm going to highlight why we recommend caching in your CI environment.

In production, the reason we cache routes and views is to get better performance. While faster tests in CI is a good thing, that's not actually the main reason we recommend caching there.

The primary benefit is to catch very subtle bugs that could otherwise slip through into production. I've seen code behave differently with route caching enabled or not. So if all of your tests and interactions locally have route caching disabled, CI is a good place to run your tests again with route caching turned on.

One thing to keep in mind: While you can cache routes and views in CI, you cannot cache configuration. The Laravel test environment cannot run with cached configuration.

Here to help,

Joel

P.S. Are you trying to find a Laravel developer for your team? Why not bring on two world-class Laravel devs instead?

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.