Performance enhancements for Magento 2
DMC_Performance is a module that summarizes some tweaks found for Magento 2. It does so without aiming to remove functionality (apart from the reports and visitor logging...).
This results in a slightly faster page load though it may not be noticeable when not comparing stats.
Currently the module was tested with Magento Open Source 2.2.2 and is depending on this version at least.
The package should be available via packagist.org, so it can be installed directly.
composer require dmc/m2-module-performance:^1.0 php bin/magento module:enable DMC_Base php bin/magento module:enable DMC_Performance php bin/magento setup:upgrade
Optionally do all the things required for production usage.
There are a few features, which can be utilized here.
When rendering a page with product images, Magento will generate product cache images on the fly which can be time intensive.
On the other hand, the image cache generation from Magento using
catalog:images:resize will usually generate too many images
not required for sure. Because of this, the generation will take a long time and create images you may not use at all.
Using the command
dmc:catalog:images:resize you can start the image resizing process which will
create cached images for Magento much faster. To do this, it will use a product collection instead of loading products one by one using load() and filter the images to create.
Beware, this is currently using a whitelist in the view.xml! There are 2 nodes you can use and you have to understand how images will be generated. Please consult the Magento documentation for image properties in themes first: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/theme-images.html
This is an example configuration you an use in your view.xml:
<!-- Generate with command dmc:catalog:image:resize -->
generate_image_ids, only the corresponding attached images to the attribute will be geenrated.
generate_gallery_image_ids, all images will be generated as the media gallery will load them as as well.
To know which image IDs will be used, you can search your code or log calls for the image cache helpers.
If you never have to remove the cached images, you can just rerun this command as a cronjob using
php bin/magento dmc:catalog:images:resize.
The collection data enhancement will collect and add data that would be loaded in single queries when visiting a list block:
Depending on how customized your code is, this can save quite some sql queries. Currently it will attache the following data: * Tier prices * Stock items (not always needed though, may be separated later) * Catalog rule prices * Category IDs
Things that will not be added with this, but could be useful depending on your code: * URL rewrites * Website IDs/Names * General attributes