"Disable Cache" is ignored when the browser is in offline mode
Categories
(DevTools :: Netmonitor, defect, P3)
Tracking
(Not tracked)
People
(Reporter: julienw, Unassigned)
References
(Depends on 1 open bug)
Details
STR:
- Go to a web page.
- Open the net monitor, and click "Disable cache"
- Put the browser in "Offline mode" (from the File menu)
- Reload the page
=> notice that the cached files are retrieved.
I wanted to test the behavior of my app when the network is down, but couldn't do it this way. I had to delete all cached data for the website instead.
(Nightly v123 20231229092537)
Comment 1•2 years ago
•
|
||
Seems like using the Offline simulation from the netmonitor's throttling menu completely prevents the page from loading, whereas the File > Offline mode still allows the page to load and fetch cached resources via service workers.
Can you share the application you were testing in offline mode? So that we can really check what should happen in this case.
For the record, disabling the cache via the netmonitor does the following:
_setCacheDisabled(disabled) {
const value = disabled
? Ci.nsIRequest.LOAD_BYPASS_CACHE
: Ci.nsIRequest.LOAD_NORMAL;
if (this._browsingContext.defaultLoadFlags != value) {
this._browsingContext.defaultLoadFlags = value;
}
}
and toggling File > Work Offline toggles Services.io.offline. Maybe there is a conflict between those 2 settings.
| Reporter | ||
Comment 2•2 years ago
|
||
I was testing with a local version of https://beta--mozilla-perfcompare.netlify.app/. There's no service worker there.
Especially I wanted to test the behavior around XHRs and fetch calls. I guess my request is to make it possible to fail these calls, but keep the navigation calls working, which is a bit different to what I was suggesting initially.
Comment 3•2 years ago
|
||
We found a few concerning issues:
- RDM offline mode does not prevent from loading / navigating, whereas the netmonitor one does
- it's not clear what Services.io.offline does, maybe it directly pulls resources from the cache and bypasses the devtools disable cache setting
Let's check both items, and revisit.
Comment 4•2 years ago
|
||
For the first item, RDM is not actually handling the offline setting at all.
The RDM implementation can be found at https://searchfox.org/mozilla-central/rev/52f45d12530f9f8da61c6c7237003b5d1499b6d1/devtools/client/responsive/ui.js#856 . There is no handling of offline.
The netmonitor implementation is at https://searchfox.org/mozilla-central/rev/52f45d12530f9f8da61c6c7237003b5d1499b6d1/devtools/client/netmonitor/src/connector/index.js#512. The offline setting is handled via target configuration, eg:
await this.commands.targetConfigurationCommand.updateConfiguration({
setTabOffline: id === throttlingProfiles.PROFILE_CONSTANTS.OFFLINE,
});
It would really be nice to have a shared command to handle throttling and use this from both RDM and netmonitor, to avoid this duplicated code and this kind of bugs. That's a separate issue, will file a dedicated bug.
Comment 5•9 months ago
|
||
This issue is actually the same as Bug 779671.
Doing a force reload (ctrl or cmd + shift + R) also doesn't do anything when offline because LOAD_FLAGS_BYPASS_CACHE is fully ignored.
Comment 6•9 months ago
|
||
Discussed a bit with Valentin on the necko channel:
There are some conflicting requirements here.
We normally want to always load from cache when the browser is offline - but we also want to test what happens when we are in offline mode and there's nothing in the cache... we have to do that slightly differently
So maybe here we should only show a warning/notification when disable cache is enabled and Services.io.offline is true, to suggest users to use the Offline throttling setting instead?
Updated•8 months ago
|
Description
•