Magento Image Cache: How can we Save Gigabytes?
Last Updated | July 6, 2023
Table of Contents
Magento Image Cache
You should read this article because will be exploring a lot related to saving huge space for Magento image cache. Read along with us If you frequently run out of storage space and someone tells you that you have many images but in fact, you don’t, this is a red flag.
Or, if you’ve already bought a second HDD for photographs, and it’s almost full, but you don’t understand why. Disclaimer! Your website will not function if the disc space runs out.
Your website will cease working and your customers will see a 503 Error Page if a database server is situated on the very same drive as the website and the media files. The server logs will also show that there is “No Space Left On Device” if this happens.
This is the tale of how we avoided caching scaled photographs on a hard drive, which allowed us to save 250GB of disc space over time.
Data For The Input
The online store now has 20864 products visible under “Catalog, Search.” This is what is obtainable and discoverable. In other words, customers notice these things and most likely have seen photographs of them.
– The values below are quite typical:
– Each product has five photos;
The image is roughly 3.5 MB in size.
As a result, it requires 365120 MB to 356 GB on average.
This number makes sense to us logically. I have a lot of pictures, and they take up a certain amount of room. But there’s a significant nuance! Your website might contain photographs of various sizes.
For instance, if the desired size for a popup or cart page is 100×100 pixels, it would be absurd to load a picture with a source size of 1000×1000 pixels. The user’s traffic will be used, and a page would load slowly.
Entrance To The Problem – Calculation Of Added Disk Space
Consider a typical website with the following pages: the homepage, category pages, product pages with the quick view and cart popup features, cart pages, checkout pages, thank you pages, and alerts that may contain product photos.
Take the 20002000 pixels image you posted to a product, for instance. This picture is the original one. This would be essential to publish the same image on one of the pages in a 500×700 pixels size, so Magento will use special capabilities to resize the image and save it in the Magento image cache. The next time we require a picture of this size, it will be loaded from the cache rather than being produced from scratch because it is saved in a specific folder.
In order to optimize, it operates in this way. An older version of the media would be used going forward to speed up image resizing, which consumes time and server resources.
Webpage Images Use Options And New File Creation Process
-
Homepage
– A banner or advertising merchandise use a 1000 x1000 pixels photo
– For a new file of a successful item use a 300×500 pixels image
– A slider banner (8 best-selling products) uses 250×300 pixels
-
Category
– New files for a Product Grid use 200×250 pixels photo
– New files Top Selling Products use 250×350 pixels photos
-
Product Page
– The main image shows that everything is in order
– For a carousel with thumbnails use a 50×50 pixels photo
– For the Customers also buy carousel use a 250×310 pixels photo
-
Elements/windows
– Shopping Cart for shopping. 40×45 pixels photo.
– For a Quick view use a 500×500 pixel photo.
You will have a lot newer picture files if you add any further promotional sections, carousels, or blogs, and export your products to a feed (like Google, Facebook, etc.) that contains image sizes. Additionally, keep in mind email alerts if they contain product photographs. So, I assume you get my position.
You will receive roughly 20 to 30 extra image sizes for each product based on this incomplete list. Given the variety of products on the website, you can have a sizable number of other files.
Magento Image Cache – How Do You Avoid Having A Full Memory Space
For a wide variety of blocks and pages, you can use a number of universal sizes. A 200×200 pixels image, for instance, might be appropriate for
– Shopping basket
– Feeds
– If photos are utilized, the Category Page or Menu
– Home page sliders
– Notifications via email
How To Identify A Problem And Its Solution?
Design. Theoretically, developers should take a variety of picture sizes into account and possibly give developers a guide for using photos on the website, noting that certain pages, such Homepage, Category, and Cart, allow the usage of single image size. There is little difference in size between these photographs, so you don’t need to adjust them and make new files. Yes, 3 picture sizes won’t be enough to properly display on your website.
However, you could still specify an appropriate size explicitly in HTML code using a few universal sizes as well as the width and height properties.
The design was given to a contractor or development firm, but neither checked the layout nor looked for bottlenecks. Perhaps you weren’t questioned about the number of products you intended to list on the website or the potential number of photographs each product might have. Or perhaps no one asked if you intended to utilize CDN and they failed to mention any potential benefits.
The Solution The Problem
The sizes of the photographs should be uniform. For examples of sizes that can be combined, see the view.xml file.
You don’t even have to adjust the parameters of functions like init($product, “related products list”) or write any code. ?> getUrl()
The issue can be fixed at the view.xml level. Simply examine the file to see which image sizes are appropriate for your situation. Change sizes from larger to smaller, but not the other way around. Maintain a standard size. For instance, if your list of sizes includes 100, 200, 300, and 350 pixels, you should keep 300 or perhaps swap it out for 250.
The image will be the ideal size and appear beautiful at both 100 pixels and 350 pixels. Avoid keeping image sizes too small, since they will appear terrible at larger sizes.
If you already use CDN, that’s excellent, but if not, you should deploy it immediately. Although it would cost you little money, now you know why it’s worthwhile.
Files, especially photos, are cached by CDN services. Therefore, you don’t need to keep updated or cached copies of the photographs on the drive! In other words, you have to create photos that are the right size because they won’t be saved to your computer but instead transmitted immediately to CDN.
If your Magento webstore uses CDN, then the action of saving a changed image to the drive (Magento saves changed images to a particular folder /pub/media/catalog/product/cache/) is unnecessary and you’re just wasting money, as CDN service keeps images and they won’t be loaded from your server.
The Conclusion
The fix to the Magento image cache would be to stop saving or caching modified image files on the HDD and maximize the cache storage time in your CDN. We chose 365 days because, for example, we are confident that a table will have 4 legs and the same appearance over the entire year. If we do need to refresh the cache for a particular product, we can do it for a specific URL or we can fully delete the cache for the entire website.
One of these firms’ key marketing cliches is “We cache traffic and save your money.” Let’s save your money now! So let us hear from your @Folio3.
FAQs: Magento Image Cache
How to optimize Magento’s performance?
To reduce database requests and speed up database response, enable flat tables. It is the easiest way for Magento 2 optimization. Use a CDN if you can, and optimize your picture files. Schedule indexer updates and turn on the Magento cron. The size of the files to be downloaded will also be smaller if gzip compression is enabled.
Why Choose Folio3 as your Magento 2 customization service?
Folio3, a Digital Transformation Powerhouse, started its operations back in 2005 and since then provided a full range of all the different services related to Magento and other eCommerce Platforms. We have made our presence in eight different countries including; the US, UK, Canada, Australia, UAE, Mexico, Pakistan and Bulgaria, and striving for more.
The Folio3 experts provide a full spectrum of multiple services, from ideation and prototyping to full-scale ERP implementation and AI-based solutions for your business. Since our teams are Magento-certified experts, we take pride in our developers, who have been helping organizations from SMBs to Fortune 500 to achieve their goals and make their online presence roar.
Who can help me with Magento migration Services?
Folio3 is among the best Magento Partner Agencies offering the best Magento 2 migration services to their clients. Our experts thoroughly analyze your and your business’s requirements and then strategize a plan specific to your needs and uniqueness for building a strong identity; while keeping everything in the migration processes from the XYZ platform to Magento 2.
Where can I look for good Magento 2 developers?
To hire the best Magento developers you need to follow the simple process listed below;
- Look for reviews and ratings
- Ask previous clients for references
- Check Magento work portfolio and credentials
- Explain the project’s specific requirements
- Allocate a sample test project
- Communication skills must be good
Or you can simply reach out to a Magento partner agency for Magento 2 integration like Folio3 which offers the best of the breed developers so you can hire Magento developers to cater to all your Magento 2 store’s needs.
What is Magento Headless Commerce?
As a frontend and backend solution bound together, Magento initially came as a monolithic commerce solution. This means that it had a common framework for building and maintaining both the topmost layer of site delivery that customers see and the bottom layer or the underlying eCommerce functionality, that powers your online store.
However, Magento has grown to accommodate the more sophisticated requirements of online merchants competing in multichannel and omnichannel environments as eCommerce has progressed.
For this reason, they have made it possible for retailers to use Magento headless by separating the head from their backend functions.