We are building a very transnational membership portal on sitecore platform. So Rendering output caching is not a good option for us.

Per this htm-caching guideline (https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching), we would like all the static contents such as JS, CSS, Images etc to be cached by both user browser as well as CDN. This means setting the cache-control as public, max-age: 1 week and appropriate ETAG).

At the same time there will be static user specific PDF files which should be set as Private ,max-age:0,no-store).

Is there a best way to configure above using sitecore (configuration or custom code or module)?

  • 1
    Not sure if I understand everything correctly... JS, CSS, Images will be stored in a CDN but not in Sitecore. While static user specific PDF files will be in Sitecore?
    – Koen Heye
    Nov 14, 2016 at 19:05

1 Answer 1


Sitecore comes with out of the box possibilities to configure media caching.
Have a look at the Sitecore.config:

        The <see cref="HttpCacheability">cacheability</see> to use in media response headers.
        Possible values: NoCache, Private, Public, Server, ServerAndNoCache, ServerAndPrivate
        Default value: private
<setting name="MediaResponse.Cacheability" value="private"/>
<!--  MEDIA RESPONSE - CacheExtensions
        The <see cref="HttpCachePolicy.AppendCacheExtension">cache extension(s)</see> to use in media response headers.
        Default value: ""
<setting name="MediaResponse.CacheExtensions" value=""/>
        The <see cref="HttpCachePolicy.SetMaxAge">max age</see> to use in media response headers.
        Set it to "00:00:00" to omit this header.
        Default value: 7.00:00:00 (seven days)
<setting name="MediaResponse.MaxAge" value="7.00:00:00"/>
        The <see cref="HttpCachePolicy.SetSlidingExpiration">sliding expiration</see> to use in media response headers.
        Set it to "" to omit this header. To include it, use "true" or "false".
        Default value: ""
<setting name="MediaResponse.SlidingExpiration" value=""/>
        Specifies the value for the Vary HTTP header to use in media response headers.
        Set it to "" to omit this header.
        Default value: ""
<setting name="MediaResponse.VaryHeader" value=""/>

These are used in the MediaRequestHandler. Check the handlers section of your Web.config file.

<add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" name="Sitecore.MediaRequestHandler"/>

If you want the static user specific PDF files set up correctly, you would need to:

  • Not change the MediaResponse.Cacheability since it is already set to private
  • Set the MediaResponse.MaxAge to 00:00:00.
  • No-store should also already be present due to the setting DisableBrowserCaching.

      If true, all pages will have:
        Cache-Control: no-cache, no-store
        Pragma: no-cache
      in the http header
<setting name="DisableBrowserCaching" value="true"/>

You can modify the MediaRequestHandler to tailor it more to your needs. For example: only logged in users to a specific domain can download media files. Read this blog for some more information: http://www.doodle.co.uk/blogs/2015/03/03/restricting-access-to-sitecore-media-items

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.