CMS automatically set Cache Control to public for content media when you are not logged in, if you are logged in it will be private, see this section for configuration: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Configuration/Configuring-staticFile/
You could also use the open-source CDN module to enable aggresive caching with semi-friendly URLs to make maximum use of your CDN, I would think that is your best bet, see: https://github.com/bjuris/EPiServer.CdnSupport
Is it possible to override the default behavior so we can cache images/css/js for the users that are logged in?
In other words can we set the cache-control to public for media assets for logged in users?
Thanks
Yes, just change configuration per the link above. It defaults to the behaviour I mentioned.
We are hosting EPiServer on AWS platform. We want to leverage CloudFront CDN. We have run into several issues that has made this a little bit challenging.
1. Our initial attempt was to store the images in S3 and use URL rewriting to insert the CDN endpoint in the path so our client browsers directly download content from CDN. This was working however the URL's were not SEO friendly. So we had to given up on serving content directly out of S3 bucket.
2. Our 2nd attempt to leverage CDN was to put our entire website behind AWS Cloud front. Even though our images are still stored in S3 our HTTP requests go from Cloudfront to AWS ELB to EC2 instances. Which fetch content from S3, provide friendly names for images. This is not as nice as option 1 because web servers have to perform extra processing. I am running into an issue where EPiServer is marking the content with cache-control: private which prevents caching of dynamic content.
I found a similar issue in this forum
http://world.episerver.com/forum/developer-forum/-EPiServer-75-CMS/Thread-Container/2015/12/prevent-cache-control-private/
the solution suggested requires over riding the base page:
var cache = System.Web.HttpContext.Current.Response.Cache;
cache.SetExpires(DateTime.UtcNow.AddMinutes(15));
httpCacheability="Public" uiEditorCssPaths="" urlRebaseKind="ToRootRelative"
pageUseBrowserLanguagePreferences="false" uiShowGlobalizationUserInterface="true"
subscriptionHandler="EPiServer.Personalization.SubscriptionMail,EPiServer"
uiMaxVersions="20" pageValidateTemplate="false" uiUrl="~/adminui/CMS/" />
We also added:
It will be helpful to get your guidance on 1 and 2. Is there any way to get friendly names and still serve images/css/js directly out of S3. This is our preferred approach.
If the answer is no than we need to know the settings in web.config that should set the cachebility to Public instead of private.
Raj