24 C
Jaipur
Saturday, October 24, 2020

How To Properly Do Route Caching – Linux Hint

Must read

Maharashtra Government invites Tesla to set up a local plant | TechRadar

Elon Musk recently talked about how Tesla would come to India in 2021. While that could have many meanings, local governments are now taking...

VPN’s coming-of-age: A discussion with the ExpressVPN co-founders

It feels like VPNs are suddenly everywhere. What was once a technology used only by IT professionals and large businesses has now become a...

World Series live stream 2020: how to watch Dodgers vs Rays game 3 anywhere now

In a matter of days, the year's shortened MLB season will crown a new champion, but who will it be? The 2020 World Series...

Skype is back, and wants to take on Zoom

The pandemic has seen demand for video conferencing software skyrocket as businesses use the technology to work from home and students use it for...

If you are looking to get the most out of your Laravel application load time, you might want to take a look at route caching. One of the pieces of Laravel’s bootstrap that can take anywhere from a dozen to a few hundred milliseconds is parsing the routes files, and route caching speeds up this process significantly.

To cache your routes file, you need to be using all controller and resource routes (no route closures). If your app is not using any route closures, you can run php artisan route:cache Laravel will serialize the results of your routes files. If you want to delete the cache, run php artisan route:clear.

Minor Drawback

If you do decide to take me up on this, then be aware that Laravel will now match routes against that cached file instead of your actual routes files. You can make endless changes to those files and they won’t take effect until you run route:cache again. This means you will have to recache every time you make a change, which introduces a lot of potential for confusion.

Advice

It is recommended that you only cache in production. Since Git ignores the route cache file by default, consider only using route caching on your production server, and run the php artisan route:cache command every time you deploy new code (whether via a Git post-deploy, a Forge deploy command, or as a part of whatever other deploy system you use). This way you won’t have the confusing local development issues, but your remote environment will still benefit from route caching.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Maharashtra Government invites Tesla to set up a local plant | TechRadar

Elon Musk recently talked about how Tesla would come to India in 2021. While that could have many meanings, local governments are now taking...

VPN’s coming-of-age: A discussion with the ExpressVPN co-founders

It feels like VPNs are suddenly everywhere. What was once a technology used only by IT professionals and large businesses has now become a...

World Series live stream 2020: how to watch Dodgers vs Rays game 3 anywhere now

In a matter of days, the year's shortened MLB season will crown a new champion, but who will it be? The 2020 World Series...

Skype is back, and wants to take on Zoom

The pandemic has seen demand for video conferencing software skyrocket as businesses use the technology to work from home and students use it for...

Illinois vs Wisconsin live stream: how to watch Big Ten college football anywhere

While NCAA college football has been in action for a few weeks, the 2020/21 season only feels truly underway now the Big Ten are...