Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

do73's avatar
Level 1

Exclude routes that use Closure from caching

As you might be aware, the artisan route:cache command throws a LogicException when there are any routes that use a Closure. I need these routes, but would still like to be able to cache my other conventional routes. Is it possible to exclude certain routes from caching?

0 likes
2 replies
Niush's avatar

In Laravel 8 and above, route:cache also works with Closure. Update to these newer versions of Laravel to utilize the feature.

do73's avatar
Level 1

@Niush Thanks, I didn't know that! Unfortunately my project is stuck with Laravel 6 for the time being so I ended up creating controllers to handle the routes.

Please or to participate in this conversation.