November Happy Hour will be moved to Thursday December 5th.

Leverage browser caching in Episerver for CMS admin images or site assets

Vote:
 

Hello,

I am checking my website performance speed at Google PageSpeed Insights

I am referring below url , and with the help of this I am able to cache my static images

https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Caching/Object-caching/

but how can I cache image that are uploaded from CMS (that is siteassets).

Currently In my web.config file I have set








 
 
 

 
 
 
 
 
 
 
 
 
 



#180966
Aug 03, 2017 13:18
Vote:
 

I recall reading that the staticFile-element might need to be put inside some <location>-elements as well.

When you set far future times it might be smart to add https://github.com/bjuris/EPiServer.CdnSupport to your site also to add some uniqueness to the media URLs.

#181781
Aug 29, 2017 21:45
Vote:
 

For anyone who has come accross this and is struggling to get any of the globalassets cached, I used the following code:

public class MediaHandler : BlobHttpHandler, IRenderTemplate<MediaData>
{
protected override Blob GetBlob(HttpContextBase httpContext)
{
var binary = ServiceLocator.Current.GetInstance<IContentRouteHelper>().Content as IBinaryStorable;
return binary?.BinaryData;
}
}

I then found that the E-Tag and the Expires headers were correctly set on the blobs, and PageSpeed was happy enough with it. 

#191118
Apr 20, 2018 10:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.