Skip to content

implement options to fetch #7

Description

@jimmywarting
  • network-only: always download latest from network

  • cache-only: always load from cache storage (fail if not cached)

  • cache-first: load from cache if it exist, otherwise download, cache & load from network

  • network-first: always download latest from network, if it fail: use cache

  • fastest: Promise.race solution that loads from both cache and network, when the network completes, then it will also store it to cache

this ideas namely comes from https://googlechromelabs.github.io/sw-toolbox/api.html#handlers

there could also be some solutions that works with cache headers in the response...

Activity

  1. zachsa commented on Jul 4, 2022

    @zachsa

    Hi,

    I also would like the HTTP modules to be cached on the first Node.js startup (otherwise I spend quite a lot of time waiting for HTTP imports to load).

    Please let me know if the pull request is suitable @joeldenning! I did see that there is another open pull request (#5, #6). But I found switching to the make-fetch-happen library seems to make caching easier.

  2. zachsa commented on Jul 5, 2022

    @zachsa

    Here is the loader with caching: https://github.com/zachsa/node-loader-http/blob/fetch-caching/lib/node-loader-http.js. If there is interest in the pull request I can improve this to make the make-fetch-happen library more transparent, which (I think) allows for specifying a proxy agent such as the other pull request introduces.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions