Skip to content

Best of both worlds ... #1

@hrstoyanov

Description

@hrstoyanov

@AdamBien Thanks for the great course!

I have the following issue:
Is it possible to cache with service worker only the app specific assets, but allow the browser to load, manage and cache the D3 and LIT-HTML modules? This would result in the lowest cost for your AWS network bill, especially since D3 is 0.5mg download and you do not want to serve it from your AWS servers!

Specifically, in Air Stockz, I would like to use the free unpkg CDN to download the D3 and LIT-HTML from, instead of my AWS server, like so:

import * as d3 from 'https://unpkg.com/d3?module';
import {html, render} from 'https://unpkg.com/lit-html?module';

This works nicely without service worker! The problem is that the service worker fails to handle such downloads :

lit-html:35 GET https://unpkg.com/lib/dom.js?module net::ERR_ABORTED 404
lit-html:33 GET https://unpkg.com/lib/directive.js?module net::ERR_ABORTED 404
lit-html:36 GET https://unpkg.com/lib/part.js?module net::ERR_ABORTED 404
lit-html:31 GET https://unpkg.com/lib/template-result.js?module net::ERR_ABORTED 404
lit-html:38 GET https://unpkg.com/lib/render.js?module net::ERR_ABORTED 404
lit-html:30 GET https://unpkg.com/lib/default-template-processor.js?module net::ERR_ABORTED 404
lit-html:40 GET https://unpkg.com/lib/template-instance.js?module net::ERR_ABORTED 404
lit-html:39 GET https://unpkg.com/lib/template-factory.js?module net::ERR_ABORTED 404
lit-html:42 GET https://unpkg.com/lib/template.js?module net::ERR_ABORTED 404
lit-html:37 GET https://unpkg.com/lib/parts.js?module net::ERR_ABORTED 404

so is there a way to let the browser download (and cache) standard modules like D3 and LIT-HTML outside the service worker cache:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions