The problem that I am having is that all of the browsers I'm using are clinging on to an older version of my JavaScript file. I've tried Chrome, Firefox, IE, and Edge. I've tried manually clearing out the cache on all of those browsers. nothing seems to work. When I view source on the JavaScript file, the file is an older version of the file. Seeing I have done everything I can on the browser side, I have to assume that the version is being cached on the server side.
I am using ASP.NET Core. I am serving up files with a middleware class that I created. I am running Windows 10 Enterprise. The IIS version is: 10.0.14393.0. Here is my code:
public async Task Invoke(HttpContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); if (context.Request == null) throw new ArgumentNullException(nameof(context.Request)); // we skip the first slash and we reverse the slashes var requestFileName = context.Request.Path.Value.Substring(1).Replace("/", "\\"); //Get the directory info for the app root folder var directoryInfo = new DirectoryInfo(Path.Combine(_hostingEnvironment.ContentRootPath, "wwwroot")); //Get the file provider for the requested file var physicalFileProvider = new PhysicalFileProvider(directoryInfo.FullName); IFileInfo fileInfo = null; //Check to see if this is the xap package if (requestFileName.ToLower() == "xivic.xap") { var authToken = context.Request.QueryString.Value.Split('?')[1]; var user = DataAccessLayer<User>.GetRecord(1, new Adapt.Model.Data.ConnectionInfo(null, authToken)); //Check that the Querystring has a valid auth token if (user == null) { //The auth token is not valid so send the user the Access Denied Xap Package fileInfo = physicalFileProvider.GetFileInfo("AccessDenied.xap"); } } //Check to see if we've already got a file info or not if (fileInfo == null) { //Get the requested file info fileInfo = physicalFileProvider.GetFileInfo(requestFileName); } //Send the file to the user await context.Response.SendFileAsync(fileInfo); }
I tried to follow some links on how to clear out IIS cache, but nothing seems to work. Most forums posts tell me to recycle the app pool and I have done that many times. I did find this link:
But, I cannot find the section in IIS that it is referring to.
Lastly, I should point out that this files are not being cached when I run the app inside IIS Express. The files are only being cached when I publish to IIS.
What is going on? What part of the system is clinging on to this file? How do I clear it out?