Make Your Laravel Website Super Fast

Make Your Laravel Website Super Fast:

Laravel is the best popular back-end framework of PHP in all over the world, and lots of companies are choosing Laravel for their large and medium size projects. SEO is very important for each and every website. Here, I have listed  some tips you can follow to make your laravel app super fast. So lets Start:

1. Use Caching in production:

Your app determines the middleware , resoles aliases, resolves route groups and identifies the controller action and parameter inputs for each single route entry when you boot your laravel app. so you'll think how bad it's for you app within the production.

You can bypass the route process by caching all routes running this


 php artisan route:cache


What concerning configuration caching ?? to bypass parsing your .env and config files on each app boot you should run:


php
artisan config:cache


You can use config() to access .env variables and avoid using env()


We do not need to compile your views every time ,you should just use pre-compiled your blade template views, to do that you should run this command:


php artisan view:cache


To cache a visible of all of your app's events and listeners
you should run this command :


php artisan event:clear


Recreate boostrap/cache/compiled.php



php artisan optimize


Alert :
You need to clear all cache to reflect any new changes by using these commands:


php artisan cache:clear
php artisan view:clear

php artisan route:clear
php artisan clear-compiled
php artisan config:
cache


2. Remove Dev dependencies from composer

After you develop your project likely you'll be victimisation some Dev packages to trace queries or different development things , take away those packages World Health Organization don't seem to be needed within the production.

You should just run a single command in the production:



composer install --
prefer-dist --no-dev -o


3. Use Redis, Memcached or dynamoDB Driver

Selecting the correct cache,queue and drivers will build a distinction to application performance
In production you should use in-memory cache driver.

For queue jobs you should use Redis, SQS or Beanstalkd drivers. The Database driver is't suitable in production. For session you can use Redis, Database, Memcached or DynamoDB drivers.


4. Queue Tasks

More heavy tasks should be queued like sending emails, connecting with third party APIs and uploading large files and updating your search index.


5. Remove unused Services:

In laravel app you'll realize many services area unit unused in your product, go to

config/app.php

and this will be comment those services which are unused.


6. Use Laravel ORM over raw query

Laravel comes with Eager loading  Larave(ORM) so use it , avoid writing your own raw queries.


7. Minifying and Bundling Assets

Laravel mix can assist you here, it compiles all of your CSS and supply single app.css file, thus reducing multiple HTTP requests to single.
ou can additionally take away unused CSS from your project by using laravel-mix-purgecss package,
just install it in your development project from this command:



npm install laravel-mix-purgecss --save-dev



yarn add laravel-mix-purgecss --dev


now in your site


webpack.mix.js



const mix = require('laravel-mix');
require('laravel-mix-purgecss');

// ...

mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')



style="display:block"
data-ad-client="ca-pub-4345168151779274"
data-ad-slot="9794963263"
data-ad-format="auto"
data-full-width-responsive="true">


.purgeCss();




Post a Comment