In our Angular and MVC project, we have implemented two pages - an Online page and an Offline page in a Single Page Application (SPA) setup. The Offline page should load when the network connection is lost, and an error should be displayed when trying to access the Online page without an internet connection. To achieve this, we created a Manifest file and added it to the Layout HTML so that the application gets cached.
The issue arises when the network connection is lost and the Online page does not load due to the application cache. The solution is to remove the application cache from the browser to allow for the Offline page to function properly. We attempted to remove the cache using an MVC controller, but were unsuccessful:
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();