Skip to content

Issue with OutputCache in Blazor SSR #55534

@zubairkhakwani

Description

@zubairkhakwani

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Initially, everything functions as expected. However, upon adding the OutputCache attribute, two significant issues arise

  1. Script Functionality Breakdown: Upon revisiting the cached Home page, script functionality becomes non-responsive. Despite logging within the OnUpdate method, the console remains empty, indicating a failure in executing JavaScript functionality. This impedes the user experience and disrupts the intended behavior of the page.
  2. Excessive Reloading with Hash Navigation Furthermore, when navigating to a link within the same page containing a hash (#element), Blazor's JavaScript file (blazor.web.js) inexplicably reloads the page multiple times.

I am using BlazorPageScript nuget package provided by @MackinnonBuck to work with PageScript

If I remove @attribute [OutputCache(Duration = 2000)] it works fine.

Additionally, I've created a Video demonstrating the precise steps to replicate the issues.

untitled-video-made-with-clipchamp-1_MSVCQOmj.mp4

Expected Behavior

should works and navigating to #elements in same page should not reload pages multiple times.

Steps To Reproduce

Repo link to reproduce this issue.

minimalistic project which reproduces this issue

Exceptions (if any)

No response

.NET Version

8.0.204

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions