Speed Up Your Laravel website Super Fast | How to Increase Website Speed in Laravel - Codexashish

How to Increase Website Speed in Laravel

    Speed Up Your Laravel website Super Fast

    Laravel is the best back-end framework of PHP, and lots of companies are choosing Laravel for their large and medium-sized projects. SEO is incredibly important for each website. there are some tips you'll follow to create your laravel app super fast. So let's Start:-

    1. Use Caching in production:

    Each 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 each single route entry. so you'll be able to think how bad it's for your app within the production.

    You can bypass route processing by caching all routes running this so.:-


       php artisan route:cache


    What about configuration caching ?? to bypass parsing your .env and config files on every app boot you must run:-


       php artisan config:cache

      use config() to access .env variables , avoid using env()

    you must not compile your views whenever, just use pre-compiled blade template views, to try and do that run this command.


       php artisan view:cache


    To cache a manifest of all of your app's events and listeners

    run :

       
       php artisan event:clear

      Recreate boostrap/cache/compiled.php  



       php artisan optimize

    Alert :
    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

    2. Remove Dev dependencies from the composer

    When you develop your project likely you may be using some Dev packages to trace queries or other development things, remove those packages that aren't required within the production.

    So just run one command within the production and then.:



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

    3. Use Redis, Memcached or dynamo DB Driver

    Selecting the correct cache, queue and drivers can make a difference to application performance. In the production use an in-memory cache driver.

    For the queue jobs use the Redis, the SQS, or Beanstalkd drivers and the Database driver isn't suitable in production.

    For the session use Database, Redis, and Memcached or DynamoDB drivers.

    4. Queue Tasks

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


    5. Remove unused Services:

    In laravel app you'll find several services that are unused in your product, go to

    config/app.php

    and comment on those services which are unused.


    6. Use Laravel ORM over a raw query

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


    7. Minifying and Bundling Assets

    Laravel mix can facilitate your here, it compiles all of your CSS and supplies a single app.css file, thus reducing multiple HTTP requests to single.

    if you want, you can remove unused CSS from your project by using the laravel-mix-purgecss package,


    just install it in your development projects:-


       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();


    Conclusion:

    Speed Up Your Laravel website Super Fast. How to Increase Website Speed in Laravel.

    Do you have any queries related to This Article, Please mention it in the Comment Section of this Article, We will contact you soon.

    Thank you for reading this blog. I wish you the best in your journey in learning and mastering Laravel.

    Follow me to receive more useful content:

    Instagram | Twitter | Linkedin | Youtube

    Thank you

    People are also reading:-

    Ashish Yadav

    Hi, I am Ashish Yadav, The founder of the codexashish.com website. I am a Data Analyst by profession and a Blogger, and YouTuber by choice and I love sharing my knowledge with needy people like You. I love coding and blogging.

    Post a Comment (0)
    Previous Post Next Post