Enable Local Cache on Sitecore

Posted by

WHAT is Local Cache?

Local cache is a feature of Azure app Service, where site content is read from the local virtual machine instance. This improves the application performance and instead of retrieving it from Azure storage, Azure storage is used to store App Service content.

More details on the Local Cache can be found at MSDN pages here.

WHY Local Cache?

You will no longer experience any issues when Azure does non-maitenance storage work (moving storage as an example) which will cause application to restart.

Any accidental configuration changes or file system changes will no longer cause application to restart, unless you restart it your self.

If your code base is good, you will also experience performance boost in the application itself.

TO-DO Steps before enabling Local Cache on Sitecore App Service


  1. You want to enable Local Cache ONLY on your CD services
  2. Local Cache is not supported by Sitecore
    1. This means, if you get any kind of issues on PRODUCTION, you will need to disable Local Cache first, before working with Sitecore Support
    2. Sitecore plans to support Local Cache with Sitecore (The reference number of the request is 398580.)
  3. SOFT App Service restarts will no longer work (you need to do either full restart or stop/start)
  4. Your application cannot be larger then 2GB in total
  5. You will lose any file system Sitecore logs, so make sure Application Insights pipeline is up-to-date

Check Sitecore Application Size / Cleanup

  • Go to Kudu on your Content Delivery instance and Click on “Site Extensions“
  • Once in the “Site Extensions“ window you will see two links “Installed” and “Gallery“
    • Go to “Gallery“
    • Find “Azure Web Apps Disk Usage Site Extension“
    • Click on the “+“ sign on it
    • Once installed, on top of the window, “Restart Site” button will apear, which you will click
      • Note that this will restart your application (put it out of Traffic Manager/Load Balancer etc.)
  • Under “Installed“ you will now see “Azure Web Apps Disk Usage Site Extension“
    • Click on Play button icon on it, this will open this extension app in the new tab
    • Extension will now scan your App Service and report the sizes (NOTE: Scan can take couple of minutes, depending on your app size)
  • Once you have your app size report identify which part of application are the largest; you need to get app under 2GB in size if you want to use Local Cache
  • In my experience, largest folder will be your Sitecore Log folder and Device Detection folder
    • For Logs, either delete the older ones, or do maintenance in a way you archive the old Logs for any potential future reference
    • For Device Detection take a look at https://kb.sitecore.net/articles/872808
      • On versions 9.0 to 9.2 you have a problem where older Device Detection Databases are not cleaned up, therefore folder size is only increasing
      • Delete older Device Detection Databases and follow instruction in Sitecore’s article above
  • Once you confirmed your app is under 2GB (your “site” folder is under 2GB in size), proceed with next steps of configuration

Enable Local Cache on App Service

  • Go to “Configuration“ under “Settings“ section on your App Service
  • Add 2 new Application Settings:
      • Set the Value to “Always“
      • Set the Value to 2000
  • Save the Configuration
  • Stop/Start the App Service
  • Wait 5-15 minutes before doing the Process Explorer check

Thing we need to consider here is Local Cache Size in MB option. Here it’s set to 2000MB. This is maximum allowed size that Azure at the moment supports. If you feel comfortable you can have even smaller number. You need to be aware that your log files we continue to increase, even in Local Cache (althou is discarded at the restart).

How do You know if App Service is running under Local Cache?

  • Go back to Kudu
  • Go to Process Explorer
  • On w3wp.exe (not scm one) go to “Properties“
    • NOTE: If you see 3 processes (One SCM plus two regular), wait untill one of the w3wp.exe processes is done (creating of Local Cache is under way and it creates new IIS process for that)
  • Go to “Environment Variables“ tab
    • If it’s set to TRUE your App is running under Local Cache


  • If you are using Slots on Production env. (STG to PROD), do not enable Local Cache on Stagging Slots, only on Production
    • You are doing green-blue deployment, so you want to have latest changes on Stagging slot for check-up