How to make Magento 2 faster
Magento 2 is the leading eCommerce platform in the market. But research shows, that there are may website owners and visitors, who are not satisfied with the speed and user experience. The speed of the website is one of the main factors for cart abandonment, low conversion, low SEO rankings and so on. Therefore, it is important to solve that problem as soon as possible.
Though the speed can be connected to many many factors, in this blog post, we wrote about 3 methods, which will help you optimise your magento store and get more sales.
Full Page Cache
Magento 2 uses full page cache for CMS pages (like home page, about us), category and product pages. That means when someone visits the page for the first time, the output is cached and then is returned to the other visitors without processing (So it doesn’t generate the content again), which makes the page load minimum 5 times faster. Unfortunately it doesn’t do full page cache for Cart and Checkout pages. From Technical points of view, it doesn’t cache the pages, where there is at least one block in the layout which has cacheable=”false” attribute. Magento 2 offers 2 solutions, when it comes to storing cached page content
- File Storage – Here the cached page is stored in the var/page_cache folder
- Varnish – Here the cached page is stored in the varnish storage. This method is better and faster, but requires installing and configuring Varnish Server.
You can configure the cache storage in Stores->Configuration->System->Full Page Cache
So as you can see, Full Page Cache does a really good job, when it comes to making static, category and product pages faster.
Flat Catalog
Magento 2 uses EAV Database structure for storing categories and products. That means product and category data are stored in the multiple tables and complex SQL queries are done when it comes to showing them,saving or updating. This doesn’t sound to scary for few products, because nowdays websites use powerful servers with more then 4 GB Ram and 2 Processors. But if your store has more then few thousand products, you will see a big difference in the website speed. Magento has implemented Flat Catalog technology in order to solve this problem. It collects and stores the data in the single table and then uses that on product listing pages. The example is the category page.
This feature is disabled by default,but you can enable in the following configuration page
Stores->Configuration->Catalog->Storefront->Use Flat Catalog Category – For Categories
Stores->Configuration->Catalog->Storefront->Use Flat Catalog Product – For Products
When this feature is enabled, magento automatically does the synchronization between EAV and Flat tables when updating the product/category data on backend. This can be also done manually by running magento Reindex command.
CDN – Content Delivery Network
As you may already know, magento 2 uses a lot of static files, like css, javascript, images. So if your main page (.html) is already cached with full page cache, the remaining files are the .js, .css, .jpg, which should also be download by the browser. If the server serves static files slow, then customer will see the html coming first, and then slowly loading the data, styles and images on the page. To prevent this from happening, we recommend using CDN Services. They are basically optimised servers for storing static content. Whenever first visitor comes to the website, static files are passed through CDN server and then returned from CDN for other customers. This also fixes the problems with big amount of visitors at the same time, because now the CDN server is responsible for serving the static files.
The other adventage of CDN is that the files are saved in many locations (depending on the CDN Server), and served from the closest location. That means you will not worry about your customer’s location, because CDN service will automatically determine the customer’s location and find the best server to serve from. Popular CDN Providers are