All Articles

Configure Dianoga for a Sitecore solution

Dianoga

An automatic image optimizer for the Sitecore media library. Reduce the size of your images served from Sitecore by 8-70%, completely automatically.

When media images are requested, Dianoga automatically runs mozjpeg, PNGOptimizer, SVGO or WebP on the image data immediately after it is placed in the Sitecore media cache.

Dianoga ensures that your site is always serving fully optimised media library images even if you are using Sitecore’s dynamic resizing features. Even if you have already optimized every image uploaded into the media library, after Sitecore performs image processing the result is not optimized (an unfortunate limitation of most other image optimization libraries for Sitecore is that they only apply to the original image).

Dianoga is also great for situations where content editors may not be image editing experts and upload images that contain gobs of EXIF data and other nonessential metadata - these are removed automatically before being shown to visitors.

- Dianoga Github Repository

Steps for Installation

  1. Create a project in your Helix solution, preferably in the Feature layer for Dianoga.

    Feature.Dianoga Project in the Solution

  2. Install the latest release of the Dianoga NuGet Package over the Feature project.

    Dianoga in NuGet

  3. The installation will add the required files to the Project.

  4. Now, Publish the project to your Sitecore Instance.

  5. Open the path Sitecore-webroot/App_Data/MediaCache in File Explorer and empty that folder.

  6. Restart your Sitecore instance on IIS.

  7. Dianoga should now be configured on your site.

Verify Installation

  1. Open your latest log file and you should find an entry similar to this:

    2816 19:50:28 INFO  Dianoga: Installed optimizing media cache to provide async optimization with max 1 concurrent threads.
  2. The above log entry will ensure that Dianoga is up and running on your site.

  3. Now, try loading your site and you will notice the difference.

You can find my solution with Dianoga installed here.

https://github.com/mrvinaykj/sitecore-92-base

Notes for Solutions using PackageReference

If you are using PackageReference as a way in maintaining the NuGet packages for your solution, then the required files will not be installed on the project.

You can either install the package over the project and then switch to PackageReference for the project.

Or,

  1. Clone the repository: https://github.com/kamsar/Dianoga

  2. From the src/Dianoga folder:

    • Copy all the config files from the Default Config Files folder to the App_Config/Feature/Dianoga folder in your project.
    • Copy the Dianoga Tools folder to the App_Data folder in your project.

Notes for Solutions using TDS for Deployment

You will need to include the below DLLs to be deployed along with your project.

  1. Dianoga.dll
  2. System.Threading.Tasks.Dataflow.dll

Published May 27, 2021

Sitecore MVP Technology 2024-23. Web Developer with rich experience in Sitecore and ASP.NET MVC.