Laravel stands out as a highly sought-after web development framework, operating on PHP. It empowers developers to adopt a more structured architectural pattern, a departure from the comparatively lenient approach found in core PHP development. The latest trends indicate that approximately 650,000 websites use this framework to run their businesses.
Despite its numerous advantages, encompassing features such as a robust templating engine, middleware, and exceptional testing support, it is worth noting that Laravel may not emphasize speed performance from the end user’s standpoint. Nonetheless, its strengths lie in its comprehensive feature set, fostering a supportive community and streamlining the development process.
While it is possible to create a website solely using PHP without leveraging any framework, as the application expands, the codebase can swiftly become intricate and challenging to maintain. This is where a framework proves invaluable. By bundling essential libraries and pre-built components, a framework accelerates development, simultaneously instilling a level of organizational discipline into the code. This ensures that even sizable development teams can collaborate seamlessly without losing sight of the project’s coherence.
When considering popular frameworks, Laravel, Symfony, and CodeIgniter emerge as top contenders, followed by Zend, CakePHP, Phalcon, and others. While these frameworks greatly benefit development teams, optimizing their performance often involves additional efforts.
This may include implementing content delivery networks (CDN) to cache and compress assets like CSS and JS, converting conventional PNG and JPEG images to the more efficient AVIF and WebP formats, and incorporating lazy loading for non-critical assets. These optimizations contribute to enhancing the overall efficiency and speed of web applications built on these frameworks.
Almost all PHP frameworks have mostly these core features built that benefit the application developer and maintainer-
Having so many benefits, there are still many additional setups required to improve the Laravel website’s performance. Below are the checklist items you would like to touch upon-
Next, we are going to cover how to configure AWS, Bunny, and RabbitLoader caching on the website. All service providers have some pros and cons in their offerings and core benefits. They also differ in how much one has to spend to run them.
AWS is a known brand for its computing infrastructure. The Cloudfront CDN service has 600+ Points of Presence which gives a great service. First, you need to create a new CloudFront distribution.
After the distribution is created, you will get a distribution domain name like ‘dxxx.cloudfront.net’. This is the domain that you can now use to serve the assets of the website by replacing the original host. For example, if the current image path is –
then change it to
The change of the host for assets can be done by setting the ASSET_URL variable in the
.env file. The .env file is located in the root directory where the app is installed. This is the same directory where
composer.json file is also saved. Below is a sample content for the .env file-
After making modifications to the
.env file, make sure to clear the application cache by running the below command-
php artisan config:cache
Instead of Cloudfront, If you want to use S3 then you can explore juhasev/laravelcdn package.
Bunny is a bit pocket friendly than Cloudfront. Bunny can be used with the Laravel website as a File System Adapter. There are a few Composer packages available that make the integration a little easier. You can explore platformcommunity/flysystem-bunnycdn package and integrate it with the website.
Make sure you have a Bunny account created before you start the integration. You will also going to need a “Storage Zone” to be created in your account.
For a better performance, choose the Edge (SSD) option over Standard. the Edge (SSD) storage tier has a consistent latency of 1-5 ms while the standard tier can have a variable latency of 30-300 ms.
RabbitLoader transcends the conventional role of a CDN and caching service, offering comprehensive solutions for achieving a truly high-performing website.
RabbitLoader adds a middleware in the Laravel app and caches the entire HTML when a page is first visited. Next time when it seems the same requests, it serves the entire page from the local cache. There are two caching strategies that RabbitLoader uses-
RabbitLoader has a free tier too which is sufficient for a small website or trying the service on a non-production environment. Installing the RabbitLoader Laravel package is pretty easy and can be done in minutes.
When updating an existing CSS/JS file or an image, make sure that you use some kind of versioning in the resource path. Since the existing files are already cached on the edge servers, modifying the file on the hosting server may introduce a delay in reflecting those for the website visitors.
Below is an example where you see
'?v=1.2' appended as a GET parameter to a CSS file. When you update this file, simply change the version to
'?v=1.3' or anything of that sort that ignores the previous version of the CSS file when serving the page to visitors.
<link rel="stylesheet" href="https://mywebsite.com/assets/css/theme.css?v=1.2" />