Updated 7 December 2023
Bagisto latest version 2.0 introduces Full Page Cache support to deliver lightning-fast page loading, improved SEO, scalability, and reduced server load for enhanced eCommerce performance. Here in this article, We are going to explain the full-page cache in bagisto step by step.
Full-Page Cache is like a turbocharger for your online store. It’s a sophisticated technology that allows us to store entire web pages in a high-speed cache.
When your customer visits the website, instead of generating each page from scratch, we can instantly serve you a pre-built, fully rendered version of the page. This means faster load times, smoother navigation, and an overall snappier shopping experience.
Understanding Full Page Cache: Full Page Cache is a mechanism that stores entire HTML pages in the cache. When a request is made for the same page, the cache seamlessly serves the page without the need for re-executing server-side logic. This process allows for faster page load times as the cache provides a quick and efficient way to serve the requested page without the need to run the server-side logic again. This reduces the need for database queries, template rendering, and other resource-intensive tasks, resulting in faster page load times.
We used the Spatie Laravel Responsecache Package in Bagisto2.0
1. How to Enable Full Page Cache In Bagisto
a) Go to the .env Configuration file
b) set RESPONSE_CACHE_ENABLED=true
2. How to set Cache duration and other Configuration
Navigate to this path to adjust cache duration and explore other configuration settings for Full Page Cache in Bagisto. Here, you’ll find all the configurations related to Full Page Cache.
3. Comparison of Bagisto 2.0 With FPC and without FPC
A) Home Page
As you can see in the below image the loading page is around 81.58 milliseconds.
In the below image, you can see the page load time decreased by around 66.16 milliseconds.
B) Category Page
As you can see in the below image the loading page is around 132 milliseconds.
In the below image, you can see the page load time decreased by around 62.78 milliseconds.
Bagisto 2.0, the latest version of our e-commerce platform, brings significant enhancements to improve overall performance and user experience.
4. Supported Cache Drivers
Bagisto supports all cache drivers supported by Laravel, providing unparalleled flexibility in optimising your e-commerce application’s performance. for example…
5. Clearing Response Cache with Artisan Commands:
To effortlessly clear your application’s response cache in Bagisto, utilize the following command:
php artisan cache:clear
6. Cache invalidation
Here are some common techniques for cache invalidation in Laravel:
We created some events to automatically invalidate the cache, ensuring that we consistently retrieved updated data.
1. Create the EventServiceProvider class: We create an EventServiceProvider in the src/Providers directory. This file contains the code for the event service provider, which can be used to register events and their listeners. To register an event and its listener, you can add them to the $listen array in the EventServiceProvider class.
2. Register the service in the FPC service provider: In the FPCServiceProvider.php file, locate the boot() method. Here you can see we add EventServiceProvider within the boot() method.
For instance, in the realm of event-based cache management, consider the event ‘customer.review.update.after’ triggered from the review controller upon a review update. This seamless integration guarantees swift cache clearance or update, maintaining synchronization with the latest review modifications.
afterUpdate() method. This method clears the cache using the
forget() method when a review is updated.
Thank you for reading this tutorial. We hope you found it helpful. If you have any questions or encounter any issues, please feel free to leave a comment below.
Be the first to comment.
If you have more details or questions, you can reply to the received confirmation email.Back to Home