Archive for January, 2016

Stop Episerver From Setting Cache-Control to Private

By default Episerver sets the header for  Cache-Control to Private.  You can see this by running curl

curl -kv -o /dev/null http://world.episerver.com/articles/items/relate-intranet-demo-site/

and the following is returned:

> HTTP/1.1 200 OK
> Cache-Control: private
> Content-Type: text/html; charset=utf-8
> ETag: ""
> Server: Microsoft-IIS/7.5

This is a big deal if you want to put your site behind a CDN as the Cache-Control:private is telling your CDN not to cache the site.  I got around this by adding the following to my base page.

var cache = System.Web.HttpContext.Current.Response.Cache;

cache.SetCacheability(HttpCacheability.Public);
cache.SetExpires(DateTime.UtcNow.AddMinutes(15));

This will set the cache-control header to public and sets the expiry to 15 minutes so it expires in the CDN every 15 mins.

Sunday, January 24th, 2016 c#, Episerver No Comments
 
January 2016
M T W T F S S
« Feb    
 123
45678910
11121314151617
18192021222324
25262728293031