Saturday, July 23, 2016

Sitecore Media Library like never before. Mind it before you leave its configuration unattended

According to me this topic is mostly overlooked and realized when it is in post production environment. It isn't that the sitecore media library is simple to use perhaps it is the only area where the subject is realized when dealt with different scenario.

Here is some of the scenarios I remember at top of my head.
  • Media is cached at client or end user browser
  • Media cached at server side
  • Media is uploaded in file system and database without proper instruction set to the end-users. Then comes the problem such as multi content delivery sync with one authoring server. Architecture decision. 
  • For multi-server environments, media must be propagated from the CMS server to the
  • content delivery server(s) using the Sitecore Staging module
  • AA Compliance site where image alt text is mandatory and content author dependency on alt text.etc.
  • Performance and security concerns around media library.
  • Performance hit if stored files in database as compared to disk. 

Here is few important settings that are important to take before it is released to production.
Locate these configuration in sitecore.config

MEDIA - DISABLE FILE MEDIA
  <!--  MEDIA - DISABLE FILE MEDIA
            Enables or disables storage of media as files rather than database records.
            If true, user interfaces do not present options to store media as files.
            All files will be stored in the database, disregarding the value of the Media.UploadAsFiles setting.  
           
            Default value: false
      -->

    <setting name="Media.DisableFileMedia" value="false">

MEDIA - CACHING ENABLED -Content delivery at SERVER Side

  <!--  MEDIA - CACHING ENABLED
            Indicates if caching of media files is enabled.
            Default value: true
      -->
    <setting name="Media.CachingEnabled" value="true" />

MEDIA - MAX SIZE IN MEMORY to edit media content

   <!--  MEDIA - MAX SIZE IN MEMORY
            The maximum size of media to load into memory for processing (resizing etc.).
            Default value: 40MB
      -->

MEDIA - MAX SIZE IN DATABASE to transfer and commit media in database

 <!--  MEDIA - MAX SIZE IN DATABASE
            The maximum allowed size of media intended to be stored in a database (binary blob).
            This value must be less than the ASP.NET httpRuntime.maxRequestLength setting.
            Default value: 500MB
      -->
    <setting name="Media.MaxSizeInDatabase" value="500MB" />

MEDIA - AUTO SET ALT

 <!--  MEDIA - AUTO SET ALT
            Indicates if the Alt field on the Image template is set automatically to the file
            path when the image is uploaded. If false, the Alt field is blank.
      -->
     <setting name="Media.AutoSetAlt" value="false" />

MEDIA BROWSER CACHED 

***The most important ones. Look into this configuration carefully. Read through.
I'll give you the real time scenario. Just imagine website is developed and released to production. Everything is going fine and this website is big brand corporate facing website which is publicly available. Unfortunately there is media release that needs urgent update to important policy document without changing the media url as this media url is used everywhere in newsletter and corporate bible and so on. Now there is content author or business marketing team that wants to change the file content and upload with same file name immediately. 
BOOM! .......................
Despite all the efforts with proper publish and all the changes done correctly still the new file with same name and url is not reflecting in the content delivery website. The reason is... it is cached in client and server browser. Production support team is called for the rescue with P2 level raised as service incident request. 

https://kb.sitecore.net/articles/218124

Courtesy Sitecore.
When new content is attached to an already published media item and the media item is published again, the content change might not be reflected in the browser immediately when you access the media using its URL.
This happens because the media is cached in the browser for the time specified in the MediaResponse.MaxAge setting. If a browser has already accessed the media item, it may not perform any requests to the server and may retrieve the media item from its cache until the cached version expires.

 <!--  MEDIA RESPONSE - CACHEABILITY
            The cacheability 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 cache extension(s) to use in media response headers.
            Default value: ""
      -->
     <setting name="MediaResponse.CacheExtensions" value="" />
    <!--  MEDIA RESPONSE - MAX AGE
            The max age 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" />
     <!--  MEDIA RESPONSE - SLIDING EXPIRATION
            The sliding expiration 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="" />


Reference:

https://sdn.sitecore.net/upload/sdn5/articles%202/media/media%20facilities/sitecore%20media%20facilities.pdf



https://doc.sitecore.net/sitecore_experience_platform/content_authoring/media_items/using_media_items/upload_a_file_to_the_media_library

No comments :