if the image is already in the CDN it's returned from the CDN, Umbraco doesn't see the request.
If it's not in the CDN, you configure in Azure the location of where the images are coming from as your Umbraco site, so the CDN would make a request to Umbraco for the image at /media/1234/superboatpic.jpg
Now if you have ImageProcessor configured with it's cache also in blob storage... then ImageProcessor will look for a cached version of the processed image in it's cache storage area...
... if not, ImageProcessor will process the image with any querystring parameters and return the processed image to the CDN with direction to the cached storage location...
So there is overhead on the first request but superfast thereafter...
... what you have in your page however are relative urls in the HTML, and also img srcsets, and these are processed through Umbraco on each request and bypassing the benefits of having a CDN!
Are you able to share your configuration for this please? (web.config, cache.config and security.config)
I am also using Umbraco 8 but I noticed on your website all of your images are coming directly from your CDN url with a direct 200 get and not with a 302/200 request.
Are you using the AzureBlobCache plugin for this? I have tried replicating the behaviour of your website and there is a setting for "StreamCacheImage" but when turning this to true my images are loading from http://mywebsite.com/media/ and are very slow. When using this to false I am getting first a 302 request then 200 get to my CDN url. This is somewhat faster but still slower than my previous site.
I was previously using the package AzureCDNToolkit to get the CDN link directly with GetCropCdnURL. This was very fast but the package is no longer supported on Umbraco8. Please let me know how you have accomplished this to get the CDN cache url of images directly, thanks!
I ended up ditching azureStorageCache - because of the redirect. The way it works now it's the CDN domain (https://duckferries-web-prod.azureedge.net) is proxy is pointed to the WWW domain (https://www.duckferries.com). That way if the image is not present in the CDN you hit your webserver with ImageProcessor pipeline. You have to configure CDN to register the querystring to make it work.. That in my mentioned post above..
and the CDN is then setup, if the image doesn't exist in the CDN to request it from your site via the /media folder (including querystrings), which then enables ImageProcessor to do it's thing, and return the processed image from it's image processing cache
By default this will be via a 302 redirect
but with
<setting key="StreamCachedImage" value="true"/>
the image should be streamed back to the CDN, so future requests do not involve a redirect, or any request to the umbraco site and are served directly from the CDN.
(this is different to how you would work with the AzureCDNToolkit, where you'd be trying to get the CDN url before rendering the page)
Hi Marc, how can i configure the cdn to request media folder if the image doesnt exist? I have configured cdn using Azure and the endpoint but i cant find that option....
Thanks very much, it is working great! I was able to take your example code and added a key in my web.config for my CDN root. My endpoint is now pointing to the website root instead of Blob Storage account. Now the images are loading much faster than the delay I was getting for each image request. Very much appreciate the suggestions and example!
Thanks Marc appreciate the description of how this can be setup to work with AzureBlobCache better and I will try that also.
Umbraco V8 slow images with CDN and azure cache
Hello,
I deployed azure filesystem as well as imageprocesing pipeline with azure cache and now Im finetuning the perf and the images are super slow.
I also implemented lazy loading so content above the fold would load faster.
Now I'm dumbfounded with super slow performance of images.
If you take this page for instance - https://www.duckferries.com/bali/fast-boat-companies/eka-jaya
and when you scroll down, its super slow the loading of the images.
Any idea how to make it blazin fast? I'm looking for something 50-200 ms.
Cheers
Hi Voitech
Normally with a CDN + Azure implementation, the first request for the image is via the CDN url
eg if you have an image in Umbraco, at /media/1234/superboatpic.jpg
and your CDN domain is https://cdn.duckferries.com
Your html should render it as:
https://cdn.duckferries.com/media/1234/superboatpic.jpg
if the image is already in the CDN it's returned from the CDN, Umbraco doesn't see the request.
If it's not in the CDN, you configure in Azure the location of where the images are coming from as your Umbraco site, so the CDN would make a request to Umbraco for the image at /media/1234/superboatpic.jpg
Now if you have ImageProcessor configured with it's cache also in blob storage... then ImageProcessor will look for a cached version of the processed image in it's cache storage area...
... if not, ImageProcessor will process the image with any querystring parameters and return the processed image to the CDN with direction to the cached storage location...
So there is overhead on the first request but superfast thereafter...
... what you have in your page however are relative urls in the HTML, and also img srcsets, and these are processed through Umbraco on each request and bypassing the benefits of having a CDN!
Have a look at this site, https://www.antiquestradegazette.com/guides/collecting-guides/clarice-cliff/ and the html of how the images are written out in the src and see these are requested first via the CDN.
regards
Marc
yeah, this makes sense 100%, thanks Marc!
I want to add - I'm using Azure with Akamai CDN (because at the time of writing of this post Verizon doesn't gzip anything more than 1MB)
And then I would have URL with with and height cropping for imageprocessor, however there Azure CDN would cache only 1 image per url with querystring.
So you have to change the setting to cache each version different by querystring - Cache every unique URL
More about it you can read here https://docs.microsoft.com/en-us/azure/cdn/cdn-query-string
Hi Vojtěch,
Are you able to share your configuration for this please? (web.config, cache.config and security.config)
I am also using Umbraco 8 but I noticed on your website all of your images are coming directly from your CDN url with a direct 200 get and not with a 302/200 request.
Are you using the AzureBlobCache plugin for this? I have tried replicating the behaviour of your website and there is a setting for "StreamCacheImage" but when turning this to true my images are loading from http://mywebsite.com/media/ and are very slow. When using this to false I am getting first a 302 request then 200 get to my CDN url. This is somewhat faster but still slower than my previous site.
I was previously using the package AzureCDNToolkit to get the CDN link directly with GetCropCdnURL. This was very fast but the package is no longer supported on Umbraco8. Please let me know how you have accomplished this to get the CDN cache url of images directly, thanks!
Hello,
here is my other post about it
https://our.umbraco.com/forum/using-umbraco-and-getting-started/98364-compression-of-generated-images-via-remote-service
I ended up ditching azureStorageCache - because of the redirect. The way it works now it's the CDN domain (https://duckferries-web-prod.azureedge.net) is proxy is pointed to the WWW domain (https://www.duckferries.com). That way if the image is not present in the CDN you hit your webserver with ImageProcessor pipeline. You have to configure CDN to register the querystring to make it work.. That in my mentioned post above..
Here are my configs.
CacheConfig
here is security config.
And here is my CDN creating URL helper method
The important thing is
CdnEndpoint
which isConfigurationManager.AppSettings["mediaCdnEndpoint"]
which is my CDN proxy to WWW on Azure..
Than its uses like this
And that's it I guess, ping me if need more information..
Hi Planx42
Key thing is to make sure in your html you are requesting the image first via the CDN
and the CDN is then setup, if the image doesn't exist in the CDN to request it from your site via the /media folder (including querystrings), which then enables ImageProcessor to do it's thing, and return the processed image from it's image processing cache
By default this will be via a 302 redirect but with
the image should be streamed back to the CDN, so future requests do not involve a redirect, or any request to the umbraco site and are served directly from the CDN.
(this is different to how you would work with the AzureCDNToolkit, where you'd be trying to get the CDN url before rendering the page)
regards
Marc
Hi Marc, how can i configure the cdn to request media folder if the image doesnt exist? I have configured cdn using Azure and the endpoint but i cant find that option....
Hi Vojtěch,
Thanks very much, it is working great! I was able to take your example code and added a key in my web.config for my CDN root. My endpoint is now pointing to the website root instead of Blob Storage account. Now the images are loading much faster than the delay I was getting for each image request. Very much appreciate the suggestions and example!
Thanks Marc appreciate the description of how this can be setup to work with AzureBlobCache better and I will try that also.
is working on a reply...