Optimize Laravel website Opening speed

Source: Internet
Author: User

Laravel is a powerful framework, many components, code is also very large, its ease of use is sacrificing performance, even though it is still an excellent framework, but in the formal environment to optimize the speed of the site to improve.

1. Turn off debug

Open the. env file and set debug to False.

PHP
app_env=Localapp_debug=falseApp_key=base64:st/atfeae13eyao1raee6jc9ff+yle1se+ wtyk0h6b4=

2. Cache Routing and Configuration

PHP Artisan Route:cache

PHP Artisan Config:cache

3.Laravel optimization Command

PHP Artisan Optimize

4.composer optimization

sudo composer Dump-autoload optimize

5. Using the Laravel cache

Using the Laravel cache method caches the content, has the file cache, the database cache, the Redis cache, the use of Redis can also be used with Predis components, or a variety of caching methods combined. The use of caching in Laravel is so elegant and convenient:

PHP
$lists = Cache::remember ('travel.destination.lists', function () {     return $this->destination->getList ();});

6. Use CDN7. PHP 7 and turn on Opcache8.nginx to turn on gzip compression

Provenance (http://blog.tanteng.me/2016/06/laravel-optimize/)

Optimize Laravel website Opening speed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.