Local cache - Azure App Service (2024)

  • Article

Note

Local cache is not supported in function apps or containerized App Service apps, such as in Windows Containers or in App Service on Linux. A version of local cache that is available for these app types is App Cache.

Azure App Service content is stored on Azure Storage and is surfaced in a durable manner as a content share. This design is intended to work with a variety of apps and has the following attributes:

  • The content is shared across multiple virtual machine (VM) instances of the app.
  • The content is durable and can be modified by running apps.
  • Log files and diagnostic data files are available under the same shared content folder.
  • Publishing new content directly updates the content folder. You can immediately view the same content through the SCM website and the running app (typically some technologies such as ASP.NET do initiate an app restart on some file changes to get the latest content).

While many apps use one or all of these features, some apps just need a high-performance, read-only content store that they can run from with high availability. These apps can benefit from a VM instance of a specific local cache.

The Azure App Service Local Cache feature provides a web role view of your content. This content is a write-but-discard cache of your storage content that is created asynchronously on-site startup. When the cache is ready, the site is switched to run against the cached content. Apps that run on Local Cache have the following benefits:

  • They are immune to latencies that occur when they access content on Azure Storage.
  • They are not affected by connection issues to the storage, since the read-only copy is cached on the worker.
  • They have fewer app restarts due to storage share changes.

Note

If you are using Java (Java SE, Tomcat, or JBoss EAP), then by default the Java artifacts--.jar, .war, and .ear files--are copied locally to the worker. If your Java application depends on read-only access to other files as well, set JAVA_COPY_ALL to true for those files to also be copied. If Local Cache is enabled, it takes precedence over this Java-specific enhancement.

How the local cache changes the behavior of App Service

  • D:\home points to the local cache, which is created on the VM instance when the app starts up. D:\local continues to point to the temporary VM-specific storage.
  • The local cache contains a one-time copy of the /site and /siteextensions folders of the shared content store, at D:\home\site and D:\home\siteextensions, respectively. The files are copied to the local cache when the app starts. The size of the two folders for each app is limited to 1 GB by default, but can be increased to 2 GB. Note that as the cache size increases, it will take longer to load the cache. If you've increased local cache limit to 2 GB and the copied files exceed the maximum size of 2 GB, App Service silently ignores local cache and reads from the remote file share.

Important

When the copied files exceed the defined Local Cache size limit or when no limit is defined, deployment and swapping operations may fail with an error. See the FAQ for more information.

  • 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 cache for apps that store mission-critical data in the content store.
  • D:\home\LogFiles and D:\home\Data contain log files and app data. The two subfolders are stored locally on the VM instance, and are copied to the shared content store periodically. Apps can persist log files and data by writing them to these folders. However, the copy to the shared content store is best-effort, so it is possible for log files and data to be lost due to a sudden crash of a VM instance.
  • Log streaming is affected by the best-effort copy. You could observe up to a one-minute delay in the streamed logs.
  • In the shared content store, there is a change in the folder structure of the LogFiles and Data folders for apps that use the local cache. There are now subfolders in them that follow the naming pattern of "unique identifier" + time stamp. Each of the subfolders corresponds to a VM instance where the app is running or has run.
  • Other folders in D:\home remain in the local cache and are not copied to the shared content store.
  • App deployment through any supported method publishes directly to the durable shared content store. To refresh the D:\home\site and D:\home\siteextensions folders in the local cache, the app needs to be restarted. To make the lifecycle seamless, see the information later in this article.
  • The default content view of the SCM site continues to be that of the shared content store.

Enable Local Cache in App Service

Note

Local Cache is not supported in the F1 or D1 tier.

You configure Local Cache by using a combination of reserved app settings. You can configure these app settings by using the following methods:

  • Azure portal
  • Azure Resource Manager

Configure Local Cache by using the Azure portal

You enable Local Cache on a per-web-app basis by using this app setting:WEBSITE_LOCAL_CACHE_OPTION = Always

Local cache - Azure App Service (1)

Configure Local Cache by using Azure Resource Manager

...{ "apiVersion": "2015-08-01", "type": "config", "name": "appsettings", "dependsOn": [ "[resourceId('Microsoft.Web/sites/', variables('siteName'))]" ], "properties": { "WEBSITE_LOCAL_CACHE_OPTION": "Always", "WEBSITE_LOCAL_CACHE_SIZEINMB": "1000" }}...

Change the size setting in Local Cache

By default, the local cache size is 1 GB. This includes the /site and /siteextensions folders that are copied from the content store, as well as any locally created logs and data folders. To increase this limit, use the app setting WEBSITE_LOCAL_CACHE_SIZEINMB. You can increase the size up to 2 GB (2000 MB) per app. Note that it will take longer to load local cache as the size increases.

Best practices for using App Service Local Cache

We recommend that you use Local Cache in conjunction with the Staging Environments feature.

  • Add the sticky app setting WEBSITE_LOCAL_CACHE_OPTION with the value Always to your Production slot. If you're using WEBSITE_LOCAL_CACHE_SIZEINMB, also add it as a sticky setting to your Production slot.
  • Create a Staging slot and publish to your Staging slot. You typically don't set the staging slot to use Local Cache to enable a seamless build-deploy-test lifecycle for staging if you get the benefits of Local Cache for the production slot.
  • Test your site against your Staging slot.
  • When you are ready, issue a swap operation between your Staging and Production slots.
  • Sticky settings include name and sticky to a slot. So when the Staging slot gets swapped into Production, it inherits the Local Cache app settings. The newly swapped Production slot will run against the local cache after a few minutes and will be warmed up as part of slot warmup after swap. So when the slot swap is complete, your Production slot is running against the local cache.

Frequently asked questions (FAQ)

What if Local Cache size limit is exceeded?

When the copied files exceed the Local Cache size limit, the app will read from the remote share. However, deployment and swap operations may fail with an error. See the table below for size limits and results.

Local Cache sizeCoped filesResult
≤ 2 GB≤ Local Cache sizeReads from local cache.
≤ 2 GB> Local Cache sizeReads from remote share.
Note: Deployment and swap operations may fail with an error.

How can I tell if Local Cache applies to my app?

If your app needs a high-performance, reliable content store, does not use the content store to write critical data at runtime, and is less than 2 GB in total size, then the answer is "yes"! To get the total size of your /site and /siteextensions folders, you can use the site extension "Azure Web Apps Disk Usage."

How can I tell if my site has switched to using Local Cache?

If you're using the Local Cache feature with Staging Environments, the swap operation does not complete until Local Cache is warmed up. To check if your site is running against Local Cache, you can check the worker process environment variable WEBSITE_LOCALCACHE_READY. Use the instructions on the worker process environment variable page to access the worker process environment variable on multiple instances.

I just published new changes, but my app does not seem to have them. Why?

If your app uses Local Cache, then you need to restart your site to get the latest changes. Don’t want to publish changes to a production site? See the slot options in the previous best practices section.

Note

The run from package deployment option is not compatible with local cache.

Where are my logs?

With Local Cache, your logs and data folders do look a little different. However, the structure of your subfolders remains the same, except that the subfolders are nestled under a subfolder with the format "unique VM identifier" + time stamp.

I have Local Cache enabled, but my app still gets restarted. Why is that? I thought Local Cache helped with frequent app restarts.

Local Cache does help prevent storage-related app restarts. However, your app could still undergo restarts during planned infrastructure upgrades of the VM. The overall app restarts that you experience with Local Cache enabled should be fewer.

Does Local Cache exclude any directories from being copied to the faster local drive?

As part of the step that copies the storage content, any folder that is named repository is excluded. This helps with scenarios where your site content may contain a source control repository that may not be needed in day to day operation of the app.

How to flush the local cache logs after a site management operation?

To flush the local cache logs, stop and restart the app. This action clears the old cache.

Why does App Service starts showing previously deployed files after a restart when Local Cache is enabled?

In case App Service starts showing previously deployed files on a restart, check for the presence of the App Setting - 'WEBSITE_DISABLE_SCM_SEPARATION=true'. After adding this setting any deployments via KUDU start writing to the local VM instead of the persistent storage. Best practices mentioned above in this article should be leveraged, wherein the deployments should always be done to the staging slot which does not have Local Cache enabled.

More resources

Environment variables and app settings reference

Local cache - Azure App Service (2024)

FAQs

What is Azure App Service local cache? ›

The Azure App Service Local Cache feature provides a web role view of your content. This content is a write-but-discard cache of your storage content that is created asynchronously on-site startup.

How do I disable local cache in Azure App Service? ›

You can disable Local Cache on a per-web-app basis by using this app setting: WEBSITE_LOCAL_CACHE_OPTION = Never.

What is the default limit of local cache size in Azure App Service? ›

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).

What is local cache? ›

Local cache refers to a cache that resides in the same JVM (Java Virtual Machine) or process as your application. This is sometimes known as an "in-memory" cache because the cached data is stored in the main memory of the server running the application. The primary advantage of local caching is speed.

What is the difference between server cache and local cache? ›

Key Differences

Data Freshness: Server-side caching can centrally manage data freshness, while client-side caching may serve stale data if not properly updated. Resource Utilization: Server-side caching uses server resources and is ideal for data used by multiple users.

What is the difference between remote cache and local cache? ›

Local and remote caching flows:

Local-only caches must still use Redis for replication of invalidations. Remote-only caching might be desirable for caches that store frequently updated objects, when changes must be immediately available to all containers.

Can I delete local cache? ›

Files are removed from the cache after a short time period or when their contents take up too much disk space. However, If you need more disk space on your PC, you can clear the cache manually. In the Search box on the taskbar, enter disk cleanup.

How do I clean up Azure App Service? ›

In the Azure portal, select Resource groups from the portal menu and select the resource group that contains your app service and app service plan. Select Delete resource group to delete the resource group and all the resources. This command might take several minutes to run.

How do I clear my Azure cache? ›

1 Answer. In your portal -> My information -> click Restore default settings You'll be prompted to confirm this action. Note: By clicking this button will reset the default Dashboard and also remove all cached data.

What is the Azure cache for Azure function? ›

Azure Cache for Redis can be used as a trigger for Azure Functions, allowing you to initiate a serverless workflow. This functionality can be highly useful in data architectures like a write-behind cache, or any event-based architectures.

How does Azure CDN work? ›

Azure Content Delivery Network is a globally distributed network of servers that can efficiently deliver web content to consumers. It stores cached content on the edge servers' PoP locations that are close to users, thereby minimizing network latency.

What is the Azure cache for Redis? ›

Azure Cache for Redis is a fully managed, in-memory cache that enables high-performance and scalable architectures. Use it to create cloud or hybrid deployments that handle millions of requests per second at sub-millisecond latency—all with the configuration, security, and availability benefits of a managed service.

What is the difference between local storage and local cache? ›

Local storage is for persistently storing small user-specific data, ensuring longevity across visits. Caching, on the other hand, optimizes performance by temporarily storing frequently accessed resources to speed up page loading.

How long does local cache last? ›

For example, some browsers only refetch the latest cache files after the old files expire. This can vary between a few minutes to days or years. It depends on how often a person visits a specific website or uses that browser. However, browsers can keep items in cache indefinitely only in theory.

What happens if I remove cached data? ›

Clearing the cache on your Android is a great way to free up storage space, fix technical issues like app slowdowns, and improve performance.

Is it safe to delete application cache? ›

Clearing the cache on your Android is a great way to free up storage space, fix technical issues like app slowdowns, and improve performance. Using a cleaning app is an easy way to clear app cache and keep your phone clean in other ways too.

What is the use of Azure cache? ›

Azure Cache for Redis is a fully managed, in-memory cache that enables high-performance and scalable architectures. Use it to create cloud or hybrid deployments that handle millions of requests per second at sub-millisecond latency—all with the configuration, security, and availability benefits of a managed service.

What is the local content cache? ›

Local content caching provides a couple of important benefits: Bandwidth savings and faster load times. Some of the most commonly used web software libraries (web page "building blocks") are pulled directly from the AdBlock extension on your computer, avoiding the need to download that information from the Internet.

Top Articles
My Dog is Dying and I Can’t Afford a Vet | MetLife Pet Insurance
Ausbuildung in Germany: Vocational Training Requirements in 2023
Spasa Parish
Gilbert Public Schools Infinite Campus
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Ascension St. Vincent's Lung Institute - Riverside
Understanding British Money: What's a Quid? A Shilling?
Officially Announcing: Skyward
Momokun Leaked Controversy - Champion Magazine - Online Magazine
Maine Coon Craigslist
How Nora Fatehi Became A Dancing Sensation In Bollywood 
‘An affront to the memories of British sailors’: the lies that sank Hollywood’s sub thriller U-571
Tyreek Hill admits some regrets but calls for officer who restrained him to be fired | CNN
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Rogers Breece Obituaries
Ella And David Steve Strange
Ems Isd Skyward Family Access
Elektrische Arbeit W (Kilowattstunden kWh Strompreis Berechnen Berechnung)
Omni Id Portal Waconia
Banned in NYC: Airbnb One Year Later
Four-Legged Friday: Meet Tuscaloosa's Adoptable All-Stars Cub & Pickle
Harvestella Sprinkler Lvl 2
Is Slatt Offensive
Storm Prediction Center Convective Outlook
Experience the Convenience of Po Box 790010 St Louis Mo
modelo julia - PLAYBOARD
Poker News Views Gossip
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Pull And Pay Middletown Ohio
Tri-State Dog Racing Results
Navy Qrs Supervisor Answers
Trade Chart Dave Richard
Sweeterthanolives
How to get tink dissipator coil? - Dish De
Lincoln Financial Field Section 110
1084 Sadie Ridge Road, Clermont, FL 34715 - MLS# O6240905 - Coldwell Banker
Kino am Raschplatz - Vorschau
Classic Buttermilk Pancakes
Pick N Pull Near Me [Locator Map + Guide + FAQ]
'I want to be the oldest Miss Universe winner - at 31'
Gun Mayhem Watchdocumentaries
Ice Hockey Dboard
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
A look back at the history of the Capital One Tower
Alvin Isd Ixl
Maria Butina Bikini
Busted Newspaper Zapata Tx
2045 Union Ave SE, Grand Rapids, MI 49507 | Estately 🧡 | MLS# 24048395
Latest Posts
Article information

Author: Mr. See Jast

Last Updated:

Views: 6126

Rating: 4.4 / 5 (55 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Mr. See Jast

Birthday: 1999-07-30

Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

Phone: +5023589614038

Job: Chief Executive

Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.