Blazor: Working with static files that may be cached

Jmunndo 25 Reputation points
2024-11-20T21:09:42.15+00:00

I am working a Blazor WASM application. Lately, I have faced an issue where the updated static file, in this case a .json file, is not being read properly. I have the static file under the wwwroot folder in my Client project. My Server project is configured to read in static files. I've tried a hard refresh on the browser, clean/rebuild the solution in VS, restarted VS, deleted recent browser activity and even restarted my PC but my solution seems to continue to read the old static file. Are there any tips/suggestions on dealing with cached static files?

Developer technologies .NET Blazor
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-11-20T21:26:17.5866667+00:00

    there are two standard approaches. first is a unique name for each version (usually an version key in the name) or add random query string value.

    for dev testing, enable the dev tools, and disable caching. in the browser, you can also delete cached data for the site.

    note: also check the service worker code to how its caching.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jmunndo 25 Reputation points
    2024-11-20T21:33:42.27+00:00

    Thanks. Disabling cache in Dev Tools worked. That seems so strange. Normally, a hard refresh would resolve the issue.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.