Will grouped Laravel routes be cached? Where are they cached?


Last Update : 2023-09-22 UTC 07:59:07 AM

Answers of > Will grouped Laravel routes be cached? Where are they cached?

They are stored in bootstrap/cache w3coded cached framework folder.,Yes, if body of the group is also w3coded cached framework another group or non-closure like route.,Will w3coded cached framework grouped Laravel routes be cached? Where are they w3coded cached framework cached?,The Bootstrap Directory

Closure like group (non cacheable):

Route::group(['middleware' => ['guest'], function() {
    Route::get('/hi', function() {
        dd('Hi I am closure');

Non-closure like group

Route::group(['middleware' => ['guest'], function() {
    Route::get('/hi', 'WelcomeController@hi');
    Route::get('/bye', 'WelcomeController@bye');

In fact second example is a closure (obviously) but (my guess is) Laravel will detect the closure contains only another routes (that are "cacheable") and rewrite it behind the scenes to following (this is not precisely correct and Laravel does not rewrite anything its simple demonstration how it might look, in reality Laravel uses Illuminate\Routing\RouteCollection object):

Route::get('/hi', 'WelcomeController@hi')->middleware('guest');
Route::get('/bye', 'WelcomeController@bye')->middleware('guest');

And this is the code that determines if route is or is not "cacheable" from route.php

public function prepareForSerialization()
    if ($this->action['uses'] instanceof Closure) {
        throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");


    unset($this->router, $this->container);

Current topics : Will grouped Laravel routes be cached? Where are they cached?

Newly Added Questions

Similar Questions

Questions :

How To Group Array Key Value

Last Update : 2023-09-22 UTC 12:24:25 PM

Questions :

PhpStorm Warning For React Attributes In Jsx File With SCSS File

Last Update : 2023-09-22 UTC 12:24:16 PM

Questions :

Why Is The File Not Showing Up In Request.files And In Request.forms Instead?

Last Update : 2023-09-22 UTC 12:23:58 PM

Questions :

Proxying Assets From React App Directory In Slim Framework?

Last Update : 2023-09-22 UTC 12:23:51 PM

Questions :

Laravel 5.4 Can't Run “php Artisan Preset React” Comand

Last Update : 2023-09-22 UTC 12:23:37 PM

Questions :

How To Update Session Values Without Signing Out?

Last Update : 2023-09-22 UTC 12:23:18 PM

Questions :

Array Is Not Visible

Last Update : 2023-09-22 UTC 12:23:01 PM

Questions :

React Routing For Login Using Symfony

Last Update : 2023-09-22 UTC 12:22:54 PM

Questions :

Sanctum With React SPA Returning 419 Page Expired

Last Update : 2023-09-22 UTC 12:22:38 PM

Questions :

How Do I Import An Input String Into Another Page

Last Update : 2023-09-22 UTC 12:22:23 PM

© 2023 W3CODED - All Rights Reserved.