Skip to content

Need to clear application cache and then refresh to see the new changes on PWA enabled Blazor WebAssembly apps #18

@jsakamoto

Description

@jsakamoto

From: @fingers10
(The original post is in the Issue #17)


@jsakamoto The fix provided in the service-worker.published.js,

Change the code inside the onFetch() function from const request = shouldServeIndexHtml ? 'index.html' : event.request; to const request = shouldServeIndexHtml ? (new URL(event.request.url)).pathname.replace(/\/$/, '') + '/index.html' : event.request;.

creates a cache issue.

Steps:

  1. Deploy a blazor wasm app with pwa enabled.
  2. Now make some changes in Index.razor screen.
  3. Now publish and deploy again and navigate to index url of the app.
  4. Note that new changes will not be reflected. You need to clear application cache and then refresh to see the new changes.

Video showing the problem:

  1. I have an intial version deployed.
  2. I made code change in Index.razor by adding <h1 style="background-color:yellow">Hello, Cache Problem</h1>.
  3. Published and deployed the app.
  4. Navigated to index url of the app.
  5. Refreshed and expecting to see new changes but nothing happens.
  6. Cleared cache and refreshed. Now I can see new code changes.
CacheProblem.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions