7

I have a little ASP.NET Core web app, which has a React front end to it. Pretty much out of the box "New Project" from the VS2017 wizard and then added to.

I've now got this deploying through our build and deploy systems, and the ASP.NET Core DLLs have the build version set from the build server.

When I deploy, however, the React front end doesn't reload properly and new features don't appear. I have to ask users to ctrl-F5 to get that to update.

I added version change detection (added an API call on a controller), and window.location.reload() when it sees that client side, but then it still pulls the client files from the cache.

Can I add the version number to the urls, or to webpack or similar to force a get from the server?

UPDATE: Cache busting with create react app seems relevant. I might try that...

2
  • This is no different in principle than any other cache-busting scenario. Yes, you should version your static resources, such that referencing a new version causes a new download. That can be done via query string or by actually employing real path/filename version numbers. You should also look at your web.manifest and ensure that you're versioning that and references it holds properly. Commented Mar 4, 2019 at 17:23
  • Yes - but I don't know how to go about that inside a .net core project yet. There's a bunch of stuff that is set up and causes "magic" to happen right now. I'm trying to unpack and understand how I can go about it - but there's a lot of documentation to wade through on webpack and .net core (like the dotnet publish commannd line, and the .csproj targets that run webpack etc.) Right now webpack (i assume) is bundling all the JS and updating an index.html file to load it. I was thinking there's maybe an option to webpack to "cache bust" in some way, but not found it so far. Commented Mar 4, 2019 at 18:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.