Where does magento store its cached images?

Where does magento store its cached images?

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Where does magento store its cached images?

Magento Image Caching Explained

Magento is renowned for its robust image caching capabilities that optimize product images across various sizes efficiently. This feature enhances site performance by reducing server load and improving page rendering speeds.

1. Location of Cached Images

By default, Magento stores its cached product images in a specific directory within the media folder:

/media/wysiwyg/cache/

When you upload an image or create a new product with an image attached, Magento automatically generates multiple resized versions of that image and saves them here. The naming convention follows this pattern: MAGE-<WIDTH>_<HEIGHT>.png.

For example, if your original image is named “product.jpg” and you have configured Magento to create 200x200 px and 400x400 px thumbnails, you’ll find two files in the cache folder:

MAGE-200_200.png
MAGE-400_400.png

2. Image Cache Flushing

When you navigate to System > Cache Management and select Flush Magento Image Cache, it deletes all these cached images from the /media/wysiwyg/cache/ directory.

This is particularly useful when you’re uploading new product images or modifying existing ones, as the cache needs to be updated with the fresh versions.

https://laravelcompany.com/blog/flushing-magento-cache-tutorial/

3. Manually Caching Images

If you want to manually cache some specific images (for instance, banner images), here’s how you can do it:

  1. Upload your image file to the /media/wysiwyg/ directory.

  2. Create a new module or extend an existing one to generate the cached versions using Magento’s built-in Mage::getSingleton('catalog/product_media_config')->resize($productImage->getFile()) method.

Here’s a simplified example:

public function resizeImage()
{
    $product = Mage::registry('current_product');
    $imagePath = $this->_getProductMediaConfig()->getThumbnailUrl($product);
    $resizedImagePath = $this->_prepareResizedImagePath($imagePath);

    try {
        $newImage = new Varien_Image($imagePath);
        $newImage->resize(200, 200); // set the new dimensions
        $newImage->save($resizedImagePath);
    } catch (Exception $e) {
        Mage::log("Error resizing image: " . $e->getMessage());
    }
}

private function _prepareResizedImagePath($imagePath)
{
    $pathInfo = pathinfo($imagePath);
    $resizedPath = str_replace(
        $pathInfo['filename'] . '.' . $pathInfo['extension'],
        'MAGE-200_200.' . $pathInfo['extension'],
        $imagePath
    );
    return $resizedPath;
}

Remember to call this method whenever you want the image cached or manually after uploading a new banner.

Conclusion

Magento’s built-in image caching mechanism provides a powerful way to optimize product images and improve site performance. Understanding where these cached images are stored, how they’re generated, and how to flush them is essential for maintaining a high-performing Magento store.

By keeping your image cache clean and generating thumbnails programmatically, you can ensure that your e-commerce platform remains lean, fast, and user-friendly.

To learn more about optimizing your Magento installation, consider exploring our other tutorials:

Magento Performance Optimization Guide

Catalog Cache Performance Configuration

Our network