Azure App Service Local Cache

Performance freak
Search for a command to run...

Performance freak
No comments yet. Be the first to comment.
When you use Response.Redirect with its second parameter set to true, it triggers a call to Response.End() Response.Redirect("Login.aspx"); // default is true Response.Redirect("Login.aspx", true); // same as above This causes AS...

Using ThreadPool.QueueUserWorkItem: Helps bypass limitations when trying to run async code inside IHttpModule. Does not interfere with the ASP.NET pipeline. Email sending does not block the main thread. Calling SendMailAsync().Wait() is safe here...

Introduction In SQL Server, the bit data type is used to store boolean values (0 for false, 1 for true). However, when working with SQL Server in a .NET application using Entity Framework or LINQ to SQL, the bit field is automatically converted to a ...

System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() To avoid the ThreadAbortException error when using Response.Redirect, setting the second parameter to false is generally sufficient. However,...

In Visual Studio; Solution Explorer-Project-Properties-Application. Check "Auto-Generate binding redirects" When this is selected, versions are specified in the web.config file after the Nuget package updates. When is binding necessary? If there is...

By default, the content of your Azure App Service site is actually stored in Azure Storage and shared between the app service instances. Whenever the servers hosting your Azure Storage contents are updated (be it Windows Update or whatever), your app service will be restarted in order to point it to the new host for your files.
Azure App Service Local Cache improves performance and web app uptime by copying your files to local storage. It does so by introducing a local cache on each web app instance.
More exactly:
When you web app starts, it copies the files from central Azure Storage to your local cache.
The local cache handles reads and writes, but the writes are never sent to the central Azure Storage.
When you restart your app, it will discard the local cache and reread the files from the central Azure Storage.
When publishing changes (for example from Visual Studio), they don't become visible to your apps until restarted.
This gives you much better file read/write performance for your website. It also means you get fewer restarts due to Azure Storage Share changes (but you need to restart after publishing your app).
The Local Cache feature will host all files in /site or /siteextensions
Local Cache is not supported in the F1 or D1 tier.
If your app uses Local Cache, then you need to restart your site to get the latest changes.

Navigate App Service Panel, click Configuration, add +New application setting
Name: WEBSITE_LOCAL_CACHE_OPTION Value: Always
Checked the "Deployment slot setting" checkbox
Name: WEBSITE_LOCAL_CACHE_SIZEINMB Value: 1000
Checked the "Deployment slot setting" checkbox
Save (It restarts the app service)
By default, the local cache size is 1 GB. If your content size is over 1 GB you can change the limit up to 2 GB

The Dynamic Cache is similar to Local Cache, with one major difference:
Files written by your web app will be persisted.
This means:
The dynamic cache handles reads and writes. The writes are sent to the central Azure Storage. Other web app instances will get the updated files, but there is a delay (around 10 seconds). When publishing changes (for example from Visual Studio), there is also a delay until it propagates to the web app caches.
WEBSITE_DYNAMIC_CACHE=1 means both files and their metadata are cached. WEBSITE_DYNAMIC_CACHE=2 means only metadata is cached. This makes the cache much smaller, but you don't get the same performance increase.
You will need to navigate to;
https://yourwebsitename.scm.azurewebsites.net/ProcessExplorer and find the properties column for the w3p without the scm tag. Click Properties. And switch the Environment Variables, switch down to end of page, find WEBSITE_LOCALCACHE_READY, TRUE

Or you can check this URL :
https://YourAppServiceName.scm.azurewebsites.net/api/processes/-1
Find the following record :

For more information:
https://learn.microsoft.com/en-us/azure/app-service/overview-local-cache
https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet