Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imposible to update cached styles on production app with CSS Isolation. #49809

Closed
1 task done
Bartmax opened this issue Aug 2, 2023 · 2 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@Bartmax
Copy link
Contributor

Bartmax commented Aug 2, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using Razor Class Library and having CSS isolation, you end up with a file like:

App.styles.css

This file inside have at the very begginig the import of the isolation feature:

@import 'UILibrary.bundle.scp.css';

And you reference with a link tag and it get accesed with it's checksum like:

<link rel="stylesheet" href="/App.styles.css?v=GqIbzE0izPBAjRY8-q_8rOK0YCLsPmUezcgmh6rUIr8">

And all good, until you update the styles on the razor class library, which ends in this file: UILibrary.bundle.scp.css because that asset is heavily cached on clients like chrome and edge and because the import doesn't have any cache busting mechanism (and I don't know of any way to enforce it)

Now all your clients have the styles cached and there's no way to change the import to bust the cache, aka you cannot upgrade your app.

Expected Behavior

the import should include the hash of the file.

so

@import 'UILibrary.bundle.scp.css';

becames

@import 'UILibrary.bundle.scp.css?v=SoMeHaSh';

Steps To Reproduce

It's kind of hard to reproduce because it's easy to cache bump on localhost but you need to publish to an actual domain to see how sticky are those old values.

Exceptions (if any)

No response

.NET Version

7.0.306

Anything else?

This is a MAJOR issue, not able to update a production app without errors or maybe even being aware of it's very troublesome.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Aug 2, 2023
@Bartmax
Copy link
Contributor Author

Bartmax commented Aug 2, 2023

Workaround:

Enter the server and edit the published file updating the import statement to include a query string like this:

image

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-css-isolation This issue is related to CSS Isolation feature and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Aug 2, 2023
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
Glad that you've found a workaround. We intend to address this problem by doing the work described in #47000

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Aug 3, 2023
@ghost ghost added the Status: Resolved label Aug 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants