Friday, 29 December 2017

How to increase performance of Sitecore Application?

It's one more great year, thank you Sitecore. Today going to write a blog post related to Speedup Sitecore Instance.

"Opportunities(Users) have no patience for websites with poor load speeds"- It's True.

sitecore-application-performance


So to increase performance of normal web application, below keys are very useful:
  • Caching
  • Minimizing http request (Bundling CSS/JS)
  • Use CSS sprites to load all icons
  • Optimize Image Compression

Let's start with for Sitecore Instance in details:

Here noted down some points, hope will help.

1. Caching (HTML Cache/ Item Cache/ Data Cache/ Prefetch Cache)

Always use HTML Caching, if possible then make all the view rendering cachable.

To increase startup of application:
Should work with Prefetch cache, because item's data are already fetched from database to prefetch cache.
now let's jump to ~/app_config/prefetch/ and customize by

How much will be cache size for:
a. can limit cache size of item
b. can limit cache size of children

Which item will be cachable will listed down:
c. can preload template that most frequent pages are using
like: master components/pages based templates (header/footer)
d. can preload item
like: Home (most visited page for any site)
e. can preload child item
like: Immediate child of Home

2. Sitecore Client:

Always give limited permission to Content Author
And make sure, have no permission for Site Publish
Should have only incremental/smart publish permission
Content expiration should be enable in IIS
Don't show standard fields in Content editor
limit number of child for Parent Item to 100

3. Database:

Make sure to completely truncate tables(listed below), before publishing website
History
PublishQueue
EventQueue

4. Monitor Sitecore logs files continuously

5. Disable Search index, if not using

6. Check is there any scheduled task running in background (possibly custom task may running, disable if unwanted).

7. Use Bundling for minification of JS/CSS to improve request load time.

8. Since Fast Query and Axes.GetDescendants() both are not cachable, so try to less use.


This Year Boosting,

Merry Christmas๐ŸŽ„๐ŸŽ…๐Ÿ‘
Happy New Year✌๐ŸŽˆ๐Ÿป

Sunday, 24 December 2017

Guideline: Sitecore 9 Setup on local Machine


  • Since already prepared a ppt related to this at


     

and also uploaded updated version of ppt also attached with github repository

https://github.com/sitecorelibraries/sitecorelibraries.github.io/blob/master/Documentation/Guidlines_Sitecore9_Installation._v1.1.pptx

Please let me know if facing any issue.

Have a Good day!!!

Saturday, 23 December 2017

Dynamic Multi-Level Menu: Sitecore

multi-level-menu-sitecore
Dynamic Multi-level Menu

Requirements:
Here's a requirement where someone asking to create multi-level menu, but the condition is in future client can add more submenu level. It means unlimited level of navigation.

Resources:
With the help of controller will able to get the list of navigation item from sitecore content tree. And if in future, if someone going to add more navigation item then no need to change code logic.

Implementation:
Now at the time of rendering, we wanted to list all the navigation item with less-code smartly. Previously we were listing navitem like:
<div>
   <ul>
     @if (Model?.Items != null)
     {
            foreach (var item in Model.Items)
           {
               var hasChildren = item.Children != null && item.Children.Items.Any();
       if (hasChildren)
       {
                 <li>
                    foreach(var subitem in item)
       {
                      //again repeating above logic
       }
                </li>
       }
       else
       {
                //render logic
       }
          }
      }
</ul>
 </div>

but here we are limiting the multi-level menu, like as much as sub-items level that much time we are going to add foreach() logic. And If In future clients going to add one more sub navigation item with new level then it may impact to the application.

To outcome with this problem,

found magical component: @helper

@helper is:
  • resuable component
  • include code and markup both
  • easier to read
  • can call recursivly once write logic, even in the markup file.
  • can declare and define both in the view, to reduce complexity of the code.

Below is the code sample to write dynamic multi-level menu logic:

<div>
     <ul>
       @if (Model?.Items != null)
{
               @NavItems(Model.Items);
}
     </ul>
</div>

@helper NavItems(List<item> Items)
{
foreach (var item in Items)
 {
   var hasChildren = item.Children != null && item.Children.Items.Any();
   if (hasChildren)
   {
      <li>
         @NavItems(item);
      </li>
   }
   else
  {
      //render logic
   }
}
}

Above code are only for reference, please let me know if any query.


Have a Good Day.

Tuesday, 19 December 2017

~/App_Config/include has no config with fresh instance: sitecore 9

sitecore-config-info



It's strange but noticed that now with sitecore 9, there is no configs at path ~\App_Config\Include\
As per my understanding, now there is a config at path ~\App_config\Layer.config
which has following statements like:

  <layer name="Modules" includeFolder="/App_Config/Modules/" />
  <layer name="Custom" includeFolder="/App_Config/Include/" />
  <layer name="Environment" includeFolder="/App_Config/Environment/" />

that mean from sitecore 9, layer structure introduced for modules, custom, environment and others.
Since currently after fresh instance with sitecore 9 there is no custom configs that's why
~\App_Config\Include\ has no configs, and if we wanted to add some of the custom configs then will come under the custom Layer.


Saturday, 9 December 2017

Windows could not start the solr service on Local Computer: Sitecore 9 Installation

While Creating solr service with nssm-2.24.zip then service is created by but while trying to restart/start getting error as

Windows could not start the solr service on Local Computer. The service did not return an error. This could be an internal Windows error or an internal service error. If the problem persists, contact your system administrator.

I also faced same issue and to fix this here we have two approaches:
First one is - Please make sure command prompt is closed (where earlier you may ran solr start ), if not closed then first close the command prompt and then again restart solr service. It will work.

Second approach will have below steps:

1. from the cmd (as admin) at the path ~/nssm-2.24/win64 run the command as
> nssm remove solr

Now check from services that solr service is removed or not, if not
 then firstly stop solr service from service setting manually and then run the above command hope   will work.

2. after this, remove the existing nssm-2.24(from directory) and download this version of NSSM and extract at the same place.

3. now again create the solr service via this nssm version Issue will be resolved.

Let me know if any issue.

Have a Good Day!!!

Friday, 8 December 2017

Sitecore 9 Installation Scaffolding things

sitecore9-scaffolding

Sitecore 9 is the biggest announcement from sitecore.
And while doing the installation process on your system, it is necessary that all the prequiestics are there as well as at their right place. And here scaffolding will make more sense. Below is my observations and scaffolding things for Sitecore Instance.

Sitecore Instance Directory 
will contains:
 SIF(If doing installation things with the help of SIFLess.exe) / final script for Sitecore Installation
solrssl.ps1 (to generate ssl for solr).

Sitecore Repository Directory

Configs
extracted files of the configs file(XP0 Configuration files rev.171002.zip)
   License
License.xml
Solr
extracted file of the solr (solr-6.6.x.zip)
NSSM
extracted files of the nssm (nssm 2.24.zip)

Sitecore 9.0.0 rev. 171002 (OnPrem)_xp0xconnect.scwdp.zip

Sitecore 9.0.0 rev. 171002 (OnPrem)_single.scwdp.zip

SitecoreInstallFramework 1.0 rev. 171003.zip

With this way suppose in future we need more instances then we required to create only Another Sitecore Instance Directory and add SIF, Else everything it will take from Sitecore Repository.


Let me know your valuable feedbacks.

Have a Good Day!!!