Skip to content
Thursday, April 15
  • About Me
  • Must Watch Videos
  • Proof of Concepts (POCs)

The Tech Check

Tech from one dev to another

The Tech Check

Tech from one dev to another

  • Data Science
  • Tech
  • General
  • Proof of Concepts (POCs)
  • About Me / Products
  • Must Watch Videos
  • Data Science
  • Tech
  • General
  • Proof of Concepts (POCs)
  • About Me / Products
  • Must Watch Videos
Trending Now
  • out() vs. outE() – JanusGraph and Gremlin
  • Getting Started With JanusGraph
  • I made a website which tells if you’re wearing a mask or not – without machine learning
  • Free apps vs. Paid apps
  • Binary Search Tree Implementation in Java
  • Different ways of iterating on a HashMap in Java
Home>>Tech>>Use Config Caching to Speed Up Your Laravel App
laravel-logo-white
Tech

Use Config Caching to Speed Up Your Laravel App

Sunny SrinidhiMarch 13, 2017 636 Views0

As web developers, we’re always looking for ways to speed up our app. It’s all about milliseconds today. There are several ways by which a web app or a web service could be optimised for speed. Being one of the most used and popular PHP frameworks, Laravel has a few tricks up its sleeves to make this happen. One of them is config caching. Obviously, this is not going to make tremendous improvement, but significant enough to be written about. So what is config caching?

Well, it’s exactly what it sounds like, you cache all your configuration so that you don’t have to go looking for it every time you want to read a configuration. Laravel, as usual, has an artisan command for this:

php artisan config:cache

What does this command do? It’s common to have all sensitive configuration (such as access keys and access secrets) in the .env file in a Laravel app. These values are then read in a config file, which will then be used in the code. So the config:cache command takes all the configuration files in a project and merges them into a couple of files. These two files, config.php and services.php, are then placed in the app/bootstrap/cache/ directory. You can go in there and check how these files are generated.

There’s one thing to note here. After you use this command, the framework will bypass the env helper when you are requesting a config variable, i.e., it’ll skip the whole dotenv package. So you’ll have to change the way you read config variables. For example:

// You read from .env like this
env('GOOGLE_API_KEY');

// But now, you'll have to change it to this
config('services.google_api_key');

One more thing, it’s recommended that you cache your config only in production, because the config might change very frequently in the dev env. So the best practice is to regenerate the cache in the production env as a part of your deployment process. Every time you deploy a new release to production, you can regenerate the cache so that you always have the latest config in cache.

About the author

Sunny Srinidhi

Coding, reading, sleeping, listening, watching, potato. INDIAN.
“If you don’t have time to do it right, when will you have time to do it over?” – John Wooden

See author's posts

Share this:

  • Twitter
  • Facebook

Like this:

Like Loading...

Related

Related tags : laravellaravel speed uplaravel tutorialoptimising webphpprogrammingtips and tricksweb services
Share:

Previous Post

Secure your web app with free and valid SSL (Nginx, Ubuntu, Let’s Encrypt)

Source: Digital Ocean

Next Post

Create an animated GIF of your screencast on Linux

glenn-carstens-peters-210782-converted

Related Articles

load balancer Tech

The art of load balancing – Part 2

Tech

SpaceX shares video of successful parachute tests of the Crew Dragon spacecraft

apache_kafka_streams Tech

Simple Apache Kafka Producer and Consumer using Spring Boot

amazon athena Data ScienceTech

Query data from S3 files using Amazon Athena

Wooden order signage Tech

Sorting in MongoDB in Java using BasicDBObject

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

O’Reilly Live Online Training

Getting Started with Amazon Athena

by Sunny Srinidhi
23rd April, 2021
Register now here
Sunny Srinidhi's DEV Community Profile
AWS_Community_Builder

Follow Us

  • Twitter
  • LinkedIn
  • Medium
  • GitHub

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 20 other subscribers

Recent Posts

  • out() vs. outE() – JanusGraph and Gremlin
  • Getting Started With JanusGraph
  • I made a website which tells if you’re wearing a mask or not – without machine learning
  • Free apps vs. Paid apps
  • Binary Search Tree Implementation in Java

Categories

  • Data Science (43)
  • General (4)
  • Rants (6)
  • Smartphones (1)
  • Tech (71)

Archives

  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • October 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • June 2019
  • May 2019
  • April 2019
  • November 2018
  • August 2018
  • July 2018
  • August 2017
  • July 2017
  • June 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • September 2016
  • August 2016
  • March 2016

Tags

ai amazon apache apache kafka apache spark artificial intelligence aws best practices bigdata big data coding data science datascience data structure implementation in java data structures feature reduction feature selection java java data structures java data structures implementation java linked list example java linked list implementation javascript kafka linkedlist linked list in java linked lists machine learning machine learning models ml natural language processing nlp php programming python scikit python sklearn rants scikit scikit learn sklearn spring spring boot tech technology the fasttext series
Sunny Srinidhi | WordPress Theme Ultra Seven
%d bloggers like this: