Home > PHP Framework > Laravel > body text

Laravel website performance optimization tips

不言
Release: 2018-07-31 17:09:07
Original
3027 people have browsed it

The function of the Laravel framework is very powerful, and there are many things in it. Even so, it is still an excellent framework, but in a formal environment it must be optimized to improve the opening speed of the website. Therefore, the following article is for Everyone shared several tips for Laravel website performance optimization.

1. Turn off debug

Open the .env file and set debug to false.

APP_ENV=local
APP_DEBUG=false
APP_KEY=base64:sT/aTFeaE13eyao1Raee6jC9Ff+Yle1SE+wtyk0H6B4=
Copy after login

2. Cache routing and configuration

php artisan route:cache
php artisan config:cache
Copy after login

3.Laravel optimization command

php artisan optimize
Copy after login

4.composer optimization

sudo composer dump-autoload optimize
Copy after login

5.Use Laravel cache

Use Laravel's Cache method to cache content, including file cache, database cache, and redis cache. You can also use predis components when using redis, or you can combine multiple caching methods. Using cache in Laravel is so elegant and convenient:

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

6. Use CDN

This site uses Qiniu CDN, which gives you 20G traffic and 20G monthly I don’t remember the exact amount of storage space, but it’s enough for a small website. This is my Qiniu Cloud invitation link: https://portal.qiniu.com/signup?code=3l7l12rccmc0i

7. Use PHP 7 and enable OPcache

Use PHP 7 and turn on OPcache

This is not just a performance optimization method for Laravel websites, many of them are general website performance optimization methods, and of course there are many places that can be optimized.

The above are the techniques used by laravel websites to improve website speed. For more laravel content, please pay attention to the laravel framework introductory tutorial.

Recommended related articles:

In-depth analysis of controllers in the Laravel framework

Commonly used auxiliary functions in the Laravel framework Introduction

Related course recommendations:

The latest five Laravel video tutorial recommendations in 2017

The above is the detailed content of Laravel website performance optimization tips. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!