Table of contents
1.
Introduction
2.
Definition
3.
Advantages
4.
Disadvantages
5.
How to modify the Local Cache's size setting
6.
How the local cache modifies App Service behaviour
7.
Optimum procedures for utilising App Service Cache locally
8.
Frequently Asked Questions
8.1.
What distinguishes the local cache from the local store of the Azure App Service?
8.2.
How can I obtain Azure App Service logs?
8.3.
Describe local cache.
8.4.
What does Azure's cache storage mean?
8.5.
What is stored in the process cache?
9.
Conclusion
Last Updated: Mar 27, 2024

Overview of Azure App Service Local Cache

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

To better understand "Azure App Service Local Cache," we must first understand how App Service is hosted. In general, any App Service's related contents (code files, resources, etc.) are hosted in a Shared Content Folder to provide all of the App Service's features such as Load Balancing, etc. So, if two VMs are configured for load balancing, there will only be one shared location where all App Service content is hosted.

Azure App Service Local Cache

When these Web Apps refer to the Content Folder, there is a possibility of latency issues (though Azure App handles most of these issues), which may slow down the performance of the websites slightly. We can use the "Azure App Service Local Cache" features in such a performance-critical application.

Definition

Local Cache is a temporary area where the App Service can store all of the App Service's content. The App Service stores all of its content in each provisioned VM rather than referring to a shared location.

So, all content is duplicated if the App Service is configured in two VMs(Virtual Machine). So, reading content from a local copy is preferable to reading content from a shared location, and as a result, enabling the "App Service Local Cache" feature will improve performance slightly.

So, in a nutshell, Azure App Service Local Cache is a copy of all the content in the "Site" and "Site Extensions" folders on a local VM.

Advantages

Apps that use local cache have the following advantages.

  • They are not affected by the latencies that occur when accessing content from Azure App storage.
     
  • They are immune to planned or unplanned upgrades and other Azure App storage disruptions on servers serving the content share.
     
  • Because of storage share changes, they have fewer app restarts.

Disadvantages

The drawback of Azure App Service Local Cache

  • To clear the local cache of each VM, we must restart the App Service for each deployment.
     
  • If you write directly to the local store, you will lose all changes if the VM is relocated or restarted.

How to modify the Local Cache's size setting

The local cache size is set to 1 GB by default. This includes any locally created logs, data folders, and the /site and /site extensions folders copied from the content store. Use the app setting WEBSITE LOCAL CACHE SIZEINMB to increase this limit. You can expand the size of each app by up to 2 GB (2000 MB). It should be noted that as the size of the local cache increases, it will take longer to load.

Balance between two is necessary

How the local cache modifies App Service behaviour

  • The local store is established on the VM instance when D:\home references the app launches. D:\local is still pointing to the VM-specific temporary storage.
     
  • The shared content store's /site and /site extensions directories can be found in the local cache at D:\homesite and D:\home\siteextensions, respectively. When the app launches, the files are copied to the local store. The two folders for each app can be as large as 2 GB, but the default maximum is 1 GB. It should be noted that loading the cache will take longer as the size grows. The App Service silently disregards the local store and reads from the remote file share if you increase the local cache limit to 2 GB, and the copied files are more significant than that limit. If the limit is set to anything lower than 2 GB or there is no specified limit, and the allowed number of copied files is exceeded, deployment or swapping may encounter a problem.
     
  • The local cache is read-write. However, any modification is discarded when the app moves virtual machines or gets restarted. Do not use the local supply for apps that store mission-critical data in the content store.
     
  • D:\home\LogFiles and D:\home\Data include app data and log files. The two subfolders are kept locally on the virtual machine instance and are periodically replicated to the shared content store. Writing log files and data to these folders allows apps to persist them. However, the shared content store copy is the best attempt. Thus, log files and data may still be lost if a VM instance suddenly crashes.

Optimum procedures for utilising App Service Cache locally

We recommend using Local Cache in conjunction with the Staging Environments feature.

  • To your Production slot, add the sticky app setting WEBSITE LOCAL CACHE OPTION with the value Always. Add WEBSITE LOCAL CACHE SIZEINMB as a configuration setting to your Production slot if you're utilising it.
     
  • You should create a staging slot and publish it there. If you gain the advantages of Local Cache for the production slot, you normally don't set the staging slot to use it to provide a seamless build-deploy-test lifecycle for staging.
     
  • Test your site against your Staging slot.
     
  • When ready, issue a swap operation between your Staging and Production slots.
     
  • Name and sticky to a slot are examples of moist settings. As a result, the Local Cache app settings are carried over when the Staging slot is switched to Production. After a short while, the recently changed Production slot will run against the local cache and get warmed up as part of the slot warmup process. As a result, your Production slot uses the local cache once the slot swap is finished.
     
Its not complete

Frequently Asked Questions

What distinguishes the local cache from the local store of the Azure App Service?

Local Cache functions as a temporary location where the App Service can keep all of its content. Each provided VM houses with all of the material that the App Service stores, rather than pointing to a familiar place. Therefore, all the material would be replicated into both VMs if the App Service was configured in two.

How can I obtain Azure App Service logs?

Navigate to your app and choose App Service logs in the Azure App portal to record the error page or failed request tracing for Windows apps. Select On, followed by Save, under Detailed Error Logging or Failed Request Tracing. The App Service file system houses both varieties of log files.

Describe local cache.

Data caching locally is a method for accelerating network access to data files. When practical, it includes caching data on clients as opposed to servers. Local caching allows several networks' write operations on the same file region to be consolidated into a single write operation.

What does Azure's cache storage mean?

High-performance and scalable architectures are made possible by the fully managed in-memory cache known as Azure Cache for Redis. Utilise managed services to develop cloud or hybrid deployments that can process millions of requests per second with sub-millisecond latency thanks to their advantages in setup, security, and availability.

What is stored in the process cache?

As the name suggests, an object cache built within the same address space as your application is known as an in-process cache. The Google Guava Library offers a straightforward in-process caching API as a suitable illustration.

Conclusion

This blog covered the Overview of Azure App Service Local Cache. We have learned about the local cache and there advantages and disadvantages. If you would like to learn more, check out these articles on the following to have a better understanding:

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. 

Enrol in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Do upvote our blog to help other ninjas grow. 

Live masterclass