{"id":62,"date":"2016-01-24T20:00:31","date_gmt":"2016-01-24T20:00:31","guid":{"rendered":"http:\/\/adam.finzel.co.uk\/?p=62"},"modified":"2016-01-24T20:00:31","modified_gmt":"2016-01-24T20:00:31","slug":"stop-episerver-from-setting-cache-control-to-private","status":"publish","type":"post","link":"http:\/\/adam.finzel.co.uk\/?p=62","title":{"rendered":"Stop Episerver From Setting Cache-Control to Private"},"content":{"rendered":"<p>By default Episerver sets the header for \u00a0Cache-Control to Private. \u00a0You can see this by running curl<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -kv -o \/dev\/null http:\/\/world.episerver.com\/articles\/items\/relate-intranet-demo-site\/\r\n<\/pre>\n<p>and the following is returned:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; HTTP\/1.1 200 OK\r\n&gt; Cache-Control: private\r\n&gt; Content-Type: text\/html; charset=utf-8\r\n&gt; ETag: &quot;&quot;\r\n&gt; Server: Microsoft-IIS\/7.5\r\n<\/pre>\n<p>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. \u00a0I got around this by adding the following to my\u00a0base page.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nvar cache = System.Web.HttpContext.Current.Response.Cache;\r\n\r\ncache.SetCacheability(HttpCacheability.Public);\r\ncache.SetExpires(DateTime.UtcNow.AddMinutes(15));\r\n<\/pre>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default Episerver sets the header for \u00a0Cache-Control to Private. \u00a0You can see this by running curl and the following is returned: 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. \u00a0I got around this by adding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-c","category-episerver"],"_links":{"self":[{"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":10,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":72,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/72"}],"wp:attachment":[{"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/adam.finzel.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}