Skip to main content

Posts

String Interning in Sitecore

I am always looking at different ways of optimizing application resources in Sitecore. After all, low resources means low cost!! I came across the concept of String Interning and I got interested into it. Next, I was thinking how can I make use of it in my Sitecore instances. I started digging little bit and I found Sitecore is smart enough to already make use of it. I will share some of the findings in this post. What is String Interning?  In computer science, string interning is a method of storing only one copy of each distinct string value, which must be immutable.  What this means is if you have a string object str1 with value "Hello" and then if your code initializes another string object str2 with same value "Hello", string interning will prevent creation of second object for str2 as String Constants Pool already has a string object with same value. It will assign the reference of str1 to str2 and str2 will reuse the object that was created for str1. This obv

Sitecore CD servers triggering index update jobs?

The Problem Recently, I was checking my CD server logs for an issue that was reported and stumbled across some log entries which mentioned about index update jobs getting triggered as in snapshot below- This made me think that should these jobs actually get triggered from CDs?? The answer is NO!  Why?? Because web indexes already get updated from CM servers during item publish events etc. (if the indexes are already maintained by the CM instance). Doing the same from CD servers is redundant and increasing unwanted load of index update jobs on CD servers. Also, CD servers are only supposed to READ from indexes and not WRITE to them (in most cases) Then why are these jobs getting created? I started looking into my index configurations on CD servers and from what I could see, all the web indexes in our case on the CD instances are configured with  "onPublishEndAsync", "remoteRebuild" or "rebuildAfterFullPublish" strategies. As per Sitecore best practice, if

Script to read contents of media files attached to Sitecore media library items

Ever wondered how can we read contents of files uploaded to media library without rendering them? Recently, we needed a PowerShell script to read the content of our SVGs and create a list of SVGs which contained a pattern in them. After a little research, I came up with this script -  $item =Get-Item -Path "/sitecore/media library/<filepath here>" $mediaItem = New-Object 'Sitecore.Data.Items.MediaItem' $item; $blobField = $mediaItem.InnerItem.Fields["blob"] if($blobField){         $blobStream = $blobField.GetBlobStream()         if($blobStream){             try                 {                 $contents = New-Object byte[] $blobStream.Length                 $blobStream.Read($contents, 0, $blobStream.Length) | Out-Null             }              finally              {                     $blobStream.Close()                 }             $fileText = ([System.Text.Encoding]::Default.GetString($contents))         } } In the above script, $fileText will co

Animated GIF files become not animated after resizing in Sitecore

Maintaining websites in Sitecore helps you discover interesting issues. In this blog, we discuss one such issue :) The Problem We all know that Sitecore has the ability to resize images based on the query parameters that are supplied in a media item's URL. You must have already figured out that animated GIF files become not animated after resizing in Sitecore (it is in this blog's title itself).  Wondering why it happens? According to Sitecore in  KB1001735   -  There is no built-in .NET functionality to resize a GIF file and keep its properties (for example, the delay between frames). In this case, only the first frame of the file is displayed. As a result, the animated GIF file might become not animated after resizing it using Sitecore.   What this means is if you have a GIF like this -  and if you want to resize it in Sitecore, it will appear like this -  Sitecore has suggested a fix for it in the KB article which skips resizing of GIF files to prevent GIF files from becomin

PublishJobCleanUp and PublishOperationAgeBasedCleanUp tasks in Sitecore Publishing Service

We have been using Sitecore Publishing Service for a while now and it has helped to reduce the publishing time. It takes publishing operations to a separate server which is good architecture. Any hiccups on the publishing service side don't impact our Sitecore servers directly  and we have been enjoying it so far. The Problem.. We have faced few bumps as well on our publishing service ride. We have been facing an issue where our Sitecore Publishing Service will get unresponsive after a week of acting normal. This blocks publish operations, publishing dashboard flashes errors and content stops getting pushed to live servers. As a quick fix, we restart the publishing service and that helps to clear the clutter. We have been working on finding a permanent fix for it. The Solution.. (for now) We got in touch with Sitecore Support. After analyzing our application, logs etc. they suggested that our application publishes more than what Sitecore publishing service's  default settings a

Sitecore Indexing Manager stops showing indexes due to expired SSL certificate in SOLR

The Problem While working on Sitecore, it may happen that one of your SSL certificates may expire after some time. This can cause functionalities to break.  For e.g., I encountered a problem where the SOLR search functionalities on my local Sitecore instance stopped working. You may be having similar problem if you face following issues -  when you search a GUID in Content Editor to locate an item, it would not return any result and say that an exception has occurred.  when you try to rebuild my SOLR indexes using Rebuild Search Indexes in Control Panel, the dialog did not list any of my SOLR indexes. The Research I looked into the logs to find the root cause to the problem and found following warnings -  128216 15:40:08 WARN  IsOnline: Test connection has failed with an exception. Type: 'SolrConnectionException', Message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.' I tried to load my local SOLR instance

Sitecore PowerShell script to remove rendering parameters

This blog introduces you to concept of updating rendering and rendering parameters using Sitecore PowerShell Extension. If you are maintaining a web application based on Sitecore with loads of content items, you may be familiar with content cleanup or update requests that comes from business. This is where Sitecore PowerShell Extension comes very handy and saves our life. A little background .. We were using Media Framework based connector for Brightcove videos integration in Sitecore 8.2 website. When we upgraded to Sitecore 10.1, connector for Brightcove videos integration was also migrated from Media Framework to Data Exchange Framework. So far so good. But we realized that Media Framework based integration involved storing some video and video player related data in rendering parameters as in snapshot below -  We did not see these rendering parameters getting used anymore in Data Exchange Framework based integration. Hence, it was decided to remove these rendering parameters from r