MVC Bundling and Azure CDN caching issues

400 Views Asked by At

In a current .NET webproject with ASP.NET MVC 5.2 and WebAPI 2.2, we encounter some strange troubles with minification and bundling in local/production environments.

For local development, we won't use bundling and minification, so we created a key/value pair in our web.config to switch between those settings.

Deploy to Azure with Web Optimization v 1.1.3

The browser won't cache the bundles locally in production because the cache-control header is automatically set to no-cache. This seems to be a known issue (Cache-Control="no-cache" always in "Microsoft.AspNet.Web.Optimization" ) and their only suggestion is to downgrade to v1.1.1

After the downgrade to v1.1.1, most requests has the right value (cache-control: public), but some of them are still with no-cache, so I think the real issue isn't solved with downgrading.

Local development with Web Optimization v 1.1.1

When we turn off the CDN and minification option in our web settings, some files won't be loaded in our application.

Seems like the method IncludeDirectory doesn't work in v1.1.1 (according to an issue reported on codeplex, IncludeDirectory doesn't add path to files when debugging in version 1.1.1). Because some folders have a lot of files, it's a lot of work to manually add all these files.

0

There are 0 best solutions below