1
votes

We have an Azure App Service hosting a Web App that includes static HTML and JS content. We have found that new JavaScript content we deploy to the Web Application is not updated in browsers until we Restart the Azure App Service. We use MSBUILD driven MSDeploy to publish.

We have confirmed via Kudu that the new versions of our Java Script files are there. The file sizes and modified date/time change with our deployments, as expected.

However if we hit them in a browser (e.g. http://mysite.azurewebsites.net/theFile.js) we see an older version of the file content. This is regardless of browser, after deleting cache, running in Incognito mode, running w/ Cache Disabled in F12 Tools -- always get the old content.

If we merely restart the App Service via the Portal and re-browse we get the new content. Viola, but what's going on?

The Azure App Service hosts an ASP.NET Web API application, at version 4.6.1, 64-bit, integrated pipeline, ARR off, Always On on.

The WebAPI application has a non-default Route defined that serves out a static HTML file. That file has a link to a static JS file stored in the same folder, side-by-side, as the HTML file. We've no specific route for the JS file...but didn't think that was necessary.

The environment variable WEBSITE_LOCALCACHE_ENABLED = False.

Any tips or help greatly appreciated.

2

2 Answers

1
votes

Did you enable client cache for static contents in your web application? If you have, you can disable the cache:

<system.webServer>
    <staticContent>
      <clientCache  cacheControlMode="DisableCache" />
    </staticContent>
  </system.webServer>
0
votes

The issue corresponded to a point in our project where we were not properly updating the .NET Assembly versions during our deployments. Once we modified our code and build process to generate a new AssemblyVersion with each deployment the problem went away.

In other words, now that we're always deploying with a new 4-part .NET version we always receive the right (currently sitting in Azure) version of our Java Script files.

I note that we never, ever (and still don't) change the name of our index.html or JavaScript files.

We didn't change any Routes or Azure settings -- just correctly incremented the version. I don't have a precise explanation but this is what we now observe and are fine.