n 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 have 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”.
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.
- 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.
- 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.