Often i get a question asking How do we optimize the Sitecore media library Items and improve the performance of the website. Follow the simple checklist and ensure it is applied to all the media items.
Optimize Sitecore Media Library and Improve performance
- Ensure the cache size is sufficient, else there will be a performance hit on the site. Make sure you have specified proper prefetch cache size.(data/item/prefetch).
- Optimize all the images using TinyPng. This will reduce the image size and helps the site to load faster.
- Crop the images in proper dimensions and optimize it.
- Make sure the media library structure is well architected. This helps in reducing the clutter and improves the accessibility.
- Leverage CDN like cloudflare, AKAMAI etc in order to reduce the server load.
- Enable output caching in the code. This reduces fetching the resource file each and every time from server.
- Change Media link prefix from ~/media to -/media.
By default media link prefix is tilde(~) sign, since we are using windows server there might be an issue with the permission on the resource files. Hence change it to underscore( _ ) or hyphen (-) in the web.config file as shown below.
set the value of the “Media.MediaLinkPrefix” to alternative prefix: >
<setting name="Media.MediaLinkPrefix" value="-/media" />
add the following line to the customHandlers section, don’t remove the existing one mapped to “~/media”:
<customHandlers> <handler trigger="-/media/" handler="sitecoremedia.ashx" /> <handler trigger="~/media/" handler="sitecoremedia.ashx" /> … </customHandlers>