Skip to content

Whitelist files from service worker caching #4674

Closed
@Vinnl

Description

@Vinnl

The default service worker intercepts everything except "cross-origin traffic, like HTTP API requests, images, or embeds loaded from a different domain." This is generally great for allowing my app to work offline. I ran into one use case that is problematic with this, however: RSS feeds.

My RSS feeds are generated in the back-end. Unlike API requests, users usually visit an RSS feed directly in their browser before subscribing to it (at least in Firefox). However, instead of seeing the feed in Firefox's usual RSS feed interface, the user gets served index.html (with the 404 route) from the service worker cache.

I think this is a valid use case for overriding the default cache. Furthermore, it could be implemented without changing the default behaviour, by allowing the developer to specify a specific list of files that can be whitelisted from caching, which could be passed to sw-precache's navigateFallbackWhitelist option as a regexp of URLs not to match. The main consideration would be whether this configuration option would add too much complexity. On the one hand it's another option, on the other hand ejecting feels somewhat heavy-handed for this, and there are already sections in the README about opting out of caching and considerations to keep in mind related to intercepted requests (point 7).

Let me know whether this would fit the project - I could look at preparing a pull request.

Which terms did you search for in User Guide?

Cache feed service worker rss whitelist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions