Skip to content

Error loading from the disk cache pages obtained by blocking remote fonts. #229

Description

Prerequisites

  • [ 🗸 ] I verified that this is not a filter issue
  • [ 🗸 ] This is not a support issue or a question
  • [ 🗸 ] I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • [ 🗸 ] uBlock Origin is the only extension
    • [ 🗸 ] uBlock Origin with default lists/settings
    • [ 🗸 ] using a new, unmodified browser profile
  • [ 🗸 ] I am running the latest version of uBlock Origin
  • [ 🗸 ] I checked the documentation to understand that the issue I report is not a normal behavior

Description

When uBlock blocks remote fonts, the downloaded pages (except images) in the disk cache are not stored correctly: they are not then loaded offline, but should be loaded.

A specific URL where the issue occurs

https://example.com/

Steps to Reproduce

  1. Create a new clean Firefox profile.
  2. Install uBlock Origin (https://addons.mozilla.org/firefox/addon/ublock-origin/).
  3. In uBlock Origin, enable "no remote fonts".
  4. Go online mode and download a page (not an image), for example, https://example.com/ (checked). (I'm using localhost.)
  5. Go offline mode and hold the browser in it.
  6. The option "no remote fonts" can be turned off or not to change – it does not matter.
  7. Reload the page opened on step 4 from the disk cache. 2 options: a and b:
    7.a. Re-open the tab with this page.
    7.b.1. "Reload the page bypassing the cache" (Ctrl+F5). (The result is not important: in fact, in offline mode, this will reload the page from the disk cache without checking it.)
    7.b.2. "Reload this Page with cache" (F5).
    The page will not load from the cache, but will report a "browser is offline mode" error. But the page should load.
    Disregarding the "no remote fonts" is changing the case, but I think that the blocking is needed. Cache is also needed.

Expected behavior:

The page will load from the cache.

Actual behavior:

The page will not load from the cache.

Your environment

  • uBlock Origin version: 1.16.20.
  • Browser Name and version: Firefox 56.
  • Operating System and version: Linux Ubuntu 18.

Activity

  1. gorhill commented on Sep 18, 2018

    @gorhill
    Member

    This is unfortunately a side effect of the fix to #42 -- in which the workaround suggested by Firefox devs in https://bugzilla.mozilla.org/show_bug.cgi?id=1376932 was used.

  2. ghost added
    Firefoxspecific to Firefox
    on Sep 18, 2018
  3. gorhill commented on Sep 18, 2018

    @gorhill
    Member

    I am experimenting and it seems if I just use no-cache instead of no-cache, no-store, must-revalidate, I still cannot reproduce #42, and that also seems to fix the offline issue reported here.

  4. added
    fixedissue has been addressed
    bugSomething isn't working
    on Sep 19, 2018
  5. gorhill commented on Sep 21, 2018

    @gorhill
    Member

    I am going to revert the fix here -- the side effects are undesirable for whoever does not care to work in offline mode.

    Since either ways cause side effects which may not be acceptable to group of users, I will add an advanced setting to let users configure how uBO should affect caching for the purpose of dealing with https://bugzilla.mozilla.org/show_bug.cgi?id=1376932.

    The default value will be the one used before, i.e. the one causing the issue here.

    New advanced setting: cacheControlForFirefox1376932.

    Default value: no-cache, no-store, must-revalidate.

    If using no-cache, no-store, must-revalidate:

    • Undesirable side effect: documents themselves for which uBO has to inject CSP directives as a result of filters/ruleset won't be available offline.

    If using no-cache:

    • Undesirable side effect: One will need to explicitly cache-bypass reload a page each time uBO has to inject CSP directives as a result of filters/ruleset. Note that such cache-bypass reload does not affect only the document itself, but also all secondary resources inside that document.

    This new advanced setting will be removed once https://bugzilla.mozilla.org/show_bug.cgi?id=1376932 is fixed.

  6. ghost reopened this on Aug 13, 2019
  7. ghost added
    fixedissue has been addressed
    on Aug 13, 2019
  8. 4 remaining items

  9. uBlock-user commented on Mar 14, 2021

    @uBlock-user
  10. mpeter50 commented on Apr 12, 2024

    @mpeter50

    The referenced Bugzilla issue (https://bugzilla.mozilla.org/show_bug.cgi?id=1376932) was closed with status RESOLVED FIXED, 5 years ago.
    As I see, the cache control workaround setting still uses no-cache, no-store, must-revalidate. Is that really still needed? Was the Bugzilla issue closed by mistake?

    As I understand, websites not being available offline is not the only downside of this setting, but also more network usage which is quite bad for those on a mobile data connection, and besides that battery drain when the user is on a slow connection, limited by the network provider.

  11. stephenhawk8054 commented on Jul 10, 2024

    @stephenhawk8054
    Member

    @gorhill Sorry, is the one in this reddit thread related to this issue? OP also used no-remote-fonts: * true

    https://old.reddit.com/r/uBlockOrigin/comments/1dz6du7/i_managed_to_break_firefoxs_asset_caching/

  12. gorhill commented on Jul 10, 2024

    @gorhill
    Member

    Not directly related, the issue is injecting a CSP header in non-document resources, this also happen in Chromium as can be seen in logger when forcing a reload with cache bypass. Chromium is seemingly unaffected because it does not have that special code path taken in Firefox which also inject a cache invalidation header.

    I am not sure how far in the past is the regression, I believe at some point a test for document resource might have been removed, leading to the current issue of injecting CSP header in non-document resource. I will work on a fix.


    This is the regression, a test for document resource was removed, leading to the reported issue:
    Implement network filter option replace= (Nov 2023)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Firefoxspecific to FirefoxbugSomething isn't workingfixedissue has been addressed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions