And Make sure you Like and subscribe 😉👍👍.
Laravel is the best back-end framework of PHP, and many companies are choosing Laravel for their large and medium size projects. SEO is very important for every website. their are some tips you can follow to make your laravel app super fast.
so lets begin
Every time you boot your laravel app , your app determines the middleware , resoles aliases, resolves route groups and identifies the controller action and parameter inputs for every single route entry. so you can think how bad it is for you app in the production.
You can bypass the route processing by caching all routes running this
php artisan route:cache
What about configuration caching ?? to bypass parsing your .env and config files on every app boot you should run
php artisan config:cache
use config() to access .env variables , avoid using env()
You don't need to compile you views every time , just use pre-compiled your blade template views, to do that run this command.
php artisan view:cache
To cache a manifest of all of your app's events and listeners
php artisan event:clear
php artisan optimize
You need to clear the cache to reflect any new changes by using the commands
php artisan cache:clear php artisan view:clear php artisan route:clear php artisan clear-compiled php artisan config:cache
When you develop your project most probably you will be using some Dev packages to track queries or other development things , remove those packages who are not required in the production.
just run a single command in the production
composer install --prefer-dist --no-dev -o
Choosing the right cache,queue and drivers can make a difference to application performance
In production use in-memory cache driver.
For queue jobs use Redis, SQS or Beanstalkd drivers. Database driver is not suitable in production.
For session use Database, Redis, Memcached or DynamoDB drivers.
Heavy tasks should be queued like sending email, connecting with third party API, uploading large file and updating your search index.
In laravel app you will find several services are unused in your product, go to
and comment those services which are unused.
Larvel comes with Eager loading (ORM) so use it , avoid writing your own raw query.
Laravel mix can help you here, it compiles all your CSS and provide single app.css file, thus reducing multiple HTTP requests to single.
you can also remove unused CSS from your project by using laravel-mix-purgecss package,
just install it in your development project
npm install laravel-mix-purgecss --save-dev
yarn add laravel-mix-purgecss --dev
now in your
const mix = require('laravel-mix'); require('laravel-mix-purgecss'); // ... mix.js('resources/js/app.js', 'public/js') .sass('resources/sass/app.scss', 'public/css') .purgeCss();