Use Web Cache API for extra layer of resources caching#5379
Merged
Conversation
Member
Author
|
cc: @terrakok when you are back :) I'd like to include this into 1.10 |
terrakok
reviewed
Aug 18, 2025
Member
terrakok
left a comment
There was a problem hiding this comment.
Instead of the new ResourceReader's method I'd like to have next:
- CvrWebCache - implementation of the web cache specifically for CVR files
- in the web ResourceReader.readPart function implementation to add a logic: if the path is ended with
.cvrthen to use cached values
WDYT?
| import org.w3c.workers.Cache | ||
|
|
||
| /** | ||
| * We use [Cache] and [org.w3c.dom.WindowSessionStorage] APIs to cache the successful strings.cvr responses. |
Member
There was a problem hiding this comment.
If we use it specifically for Strings.CVR then let's rename it to StringsWebCache. Otherwise, we mustn't mention cvr in the kdoc
Member
Author
There was a problem hiding this comment.
Now it's called ResourceWebCache. It's applied for all requests which go through web resource reader (in readAsBlob).
Member
|
Might be worth to use it for all resource types |
|
Hi any progress? Would be nice to have for all resource types btw! |
7086016 to
c2dbca8
Compare
Member
Author
|
Ready for a new review. |
terrakok
reviewed
Oct 16, 2025
terrakok
approved these changes
Oct 16, 2025
eymar
added a commit
that referenced
this pull request
Oct 29, 2025
window.caches is available only secure contexts I added a check for `window.caches` availability. And skip all the logic when it's not available. It's a followup for #5379 Fixes: https://youtrack.jetbrains.com/issue/CMP-9174 ## Testing This should be tested by QA ## Release Notes N/A
eymar
pushed a commit
that referenced
this pull request
Jan 20, 2026
Compose Multiplatform v1.10.0 introduced the use of the Cache Storage API to avoid repeat http requests for resources on Web ([#5379](#5379)). In a VsCode Extension Environment, the protocol of a Web View Panel that gets used is "vscode-webview:". This does not work with the Cache Storage API and results in an error when trying to load any compose resources. This PR just ensures the protocol is http/https in order to use Cache Storage API on Web Target. Fixes https://youtrack.jetbrains.com/issue/CMP-9545/ComposeResources-on-Web-not-loading-because-Cache-Storage-API-is-not-supported-everywhere ## Testing **Describe how you tested your changes (provide a snippet or/and steps)** - I ran my vscode extension with the change and without the change **without** <img width="1658" height="753" alt="image" src="https://github.com/user-attachments/assets/367f5a41-4b0b-4262-9d38-3baca1ce0125" /> **with** <img width="1658" height="885" alt="image" src="https://github.com/user-attachments/assets/b06415df-1388-45c2-a439-21e604fc2e54" /> - I ran a regular browserDevelopmentRun to ensure caching still worked as expected <img width="1863" height="942" alt="image" src="https://github.com/user-attachments/assets/54e7dd47-084c-4514-b79b-32f35577dc92" /> ## Release Notes ### Fixes - Resources Fixes an issue where web resources failed to load when calling the Cache Storage API with unsupported protocols (e.g., vscode-webview: in VS Code webviews).
eymar
pushed a commit
that referenced
this pull request
Jan 20, 2026
Compose Multiplatform v1.10.0 introduced the use of the Cache Storage API to avoid repeat http requests for resources on Web ([#5379](#5379)). In a VsCode Extension Environment, the protocol of a Web View Panel that gets used is "vscode-webview:". This does not work with the Cache Storage API and results in an error when trying to load any compose resources. This PR just ensures the protocol is http/https in order to use Cache Storage API on Web Target. Fixes https://youtrack.jetbrains.com/issue/CMP-9545/ComposeResources-on-Web-not-loading-because-Cache-Storage-API-is-not-supported-everywhere ## Testing **Describe how you tested your changes (provide a snippet or/and steps)** - I ran my vscode extension with the change and without the change **without** <img width="1658" height="753" alt="image" src="https://github.com/user-attachments/assets/367f5a41-4b0b-4262-9d38-3baca1ce0125" /> **with** <img width="1658" height="885" alt="image" src="https://github.com/user-attachments/assets/b06415df-1388-45c2-a439-21e604fc2e54" /> - I ran a regular browserDevelopmentRun to ensure caching still worked as expected <img width="1863" height="942" alt="image" src="https://github.com/user-attachments/assets/54e7dd47-084c-4514-b79b-32f35577dc92" /> ## Release Notes ### Fixes - Resources Fixes an issue where web resources failed to load when calling the Cache Storage API with unsupported protocols (e.g., vscode-webview: in VS Code webviews). (cherry picked from commit 89f6aea)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use Web Cache API for all resources
The Cache is reset on every app launch (page refresh).
The initial idea was to reset the Cache only when a new session starts, but we risk to have an outdated resources state (it can be incompatible with the app logic expectations and lead to crashes).
Fixes https://youtrack.jetbrains.com/issue/CMP-7996
Testing
This should be tested by QA
Release Notes
Fixes - Resources