You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a WebView 2 application with a request handler that can generate preview images, which are then served to the frontend as PNG files.
These files should be cached so that they are not regenerated if the URL is the same.
When handling the request in WebView2, I include a Cache-control header of the form Cache-Control: private, must-revalidate, max-age=3600
I expect this to cache the image for an hour.
What I find though, is that the image is not cached for the entire period, WebView2 will make another request to this URL before an hour has passed.
It does not seem to follow a particular rule, the request does get cached, but it seems to rerun the request anyway.
This seems to happen after a few separate requests have been handled, the previous requests are removed from the cache.
I have also added an ETag header to the request, to verify if it is for an existing image. Even though I send this header in the request, the response never includes an equivalent 'If-None-Match' header.
I would expect WebView2 to only rerun the request when max-age has passed, and to include the 'If-None-Match' header to verify if the content is the same when the original request includes the ETag header.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
126.0.2592.102
SDK Version
1.0.2151.40
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
Setup an add_WebResourceRequested handler inside WebView2 to catch a request.
Request a resource from the frontend which matches the filter.
In the handler, set a Cache-Control Header to 'private, must-revalidate, max-age=3600' and an ETag header to '123'.
Repeat the request from the frontend multiple times for separate images.
Expected:
The first request goes to the handler, subsequent requests use the cache. The ETag is sent on any stale data as the 'If-None-Match' header.
Actual:
Some of the requests use the cache, but not all of them.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered:
I'm also seeing this problem. I'm using AddWebResourceRequestedFilter() to receive requests for images from the hosted page. The page contains dynamic content that references image URLs that are fulfilled by my filter. As I interact with the page, causing new dynamic content to be added to the DOM, I'm seeing frequent repeated requests for the same image URLs. Often these repeated requests arrive within seconds of each other.
Adding Cache-Control response headers has no effect.
(Also, like @caymaynard, I find that adding ETag response headers doesn't cause the subsequent requests to carry If-None-Match request headers, but even if it did, I'd rather not receive repeated requests at all.)
What happened?
I have a WebView 2 application with a request handler that can generate preview images, which are then served to the frontend as PNG files.
These files should be cached so that they are not regenerated if the URL is the same.
When handling the request in WebView2, I include a Cache-control header of the form
Cache-Control: private, must-revalidate, max-age=3600
I expect this to cache the image for an hour.
What I find though, is that the image is not cached for the entire period, WebView2 will make another request to this URL before an hour has passed.
It does not seem to follow a particular rule, the request does get cached, but it seems to rerun the request anyway.
This seems to happen after a few separate requests have been handled, the previous requests are removed from the cache.
I have also added an ETag header to the request, to verify if it is for an existing image. Even though I send this header in the request, the response never includes an equivalent 'If-None-Match' header.
I would expect WebView2 to only rerun the request when max-age has passed, and to include the 'If-None-Match' header to verify if the content is the same when the original request includes the ETag header.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
126.0.2592.102
SDK Version
1.0.2151.40
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
Expected:
The first request goes to the handler, subsequent requests use the cache. The ETag is sent on any stale data as the 'If-None-Match' header.
Actual:
Some of the requests use the cache, but not all of them.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: