Azure App Service Local Cache

In order to understand “Azure App Service Local Cache” better, we need to understand how App Service is being hosted. In general, for any App Service, its related contents (code files, resources etc.) are being hosted in a Shared Content Folder in order to provision all the features of the App Service like Load Balancing etc. So, if there are 2 VMs configure for Load Balancing then there would just one shared location where all the content of the App Service is hosted.

When these Web Apps refer to the Content Folder, there might be chances of Latency issues (although, Azure takes care of most of these issues) which might slow down the performance of the websites a bit. In such Performance-critical application, we can leverage the features of “Azure App Service Local Cache”.

What is “Azure App Service Local Cache”?

Local Cache is like a temporary area where the App service can store all the content related to the App Service. Instead of referring a shared location, the App Service stores all its content in each provisioned VM. So, if the App Service is being configured in 2 VMs, all the content would be copied in both the VMs. So, obviously reading the content from the local copy is better than reading them from a shared location and as a result, there would a bit of improvement of the performance when we enable the “App Service Local Cache” feature.

So, in simple words, Azure App Service Local Cache is a copy of all the content located in “Site” and “Site Extensions” folder located in a local VM.

How to enable “Azure App Service Local Cache”? 

Enable the feature by having the WEBSITE_LOCAL_CACHE_OPTION = Always as shown below.



Disadvantages of Azure App Service Local Cache
  • We need to restart the App Service for each deployment to clear the local cache of each of the VMs.
  • If you perform writes directly on the local store, you would lose all the changes whenever the VM is relocated or restarted.
Other important points about Azure App Service Local Cache
  • It’s created in the local VM on the startup of the App Service.

  • Default memory allocated is 300 MB and we can extend it to 1 GB by setting the WEBSITE_LOCAL_CACHE_SIZEINMB app setting key to 1024.

  • When the Virtual VM is re-located or the App Service is restarted, all the content in the Local Cache are cleared and its populated with the content available in the Shared Content.

  • All deployments done by all different methods (FTP, Web Deploy etc.) will still be pointed to the Shared Content area. So, in order to get these changes reflected to the local cache, the App Service needs to be restarted in order to get the new changes reflected.
Your feedback is highly appreciated.


Similar Articles