Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悶] service-worker.js pre-populates the cache for some bundles that are not present on the current page #6150

Open
maiieul opened this issue Apr 23, 2024 · 3 comments
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@maiieul
Copy link
Collaborator

maiieul commented Apr 23, 2024

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

This is a bug first encountered in Qwik UI in preview and prod. It seems to me to be a build issue, not sure if it's Rollup, Vite or the optimizer.

When our application has multiple entry files and multiple context providers, it seems that the service worker starts fetching and pre-populating the cache for some bundles that are not needed on the page.

image

As showcased in the screenshot, I understand that the context.id-DK1jWIYg.js containing the "context-2" context is downloaded through the service-worker and placed in the cache for later use. Is this the intended behavior? I feel like Qwik should be smart enough to understand that context-2 is not needed on page /1, and therefore should only be loaded on page /2.

Reproduction

https://github.com/maiieul/qwik-service-worker-dowloads-external-bundles

Steps to reproduce

  • pnpm i
  • pnpm preview

System Info

System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M2
    Memory: 5.92 GB / 24.00 GB
    Shell: 3.7.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 21.7.3 - /opt/homebrew/bin/node
    npm: 10.5.0 - /opt/homebrew/bin/npm
    pnpm: 8.14.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 124.0.6367.62
    Safari: 17.4.1
  npmPackages:
    @builder.io/qwik: ^1.5.2 => 1.5.2 
    @builder.io/qwik-city: ^1.5.2 => 1.5.2 
    undici: * => 6.13.0 
    vite: ^5.1.6 => 5.2.9 


### Additional Information

_No response_
@maiieul
Copy link
Collaborator Author

maiieul commented Apr 23, 2024

Heads up 馃憜

The Qwik UI issue above (qwikifiers/qwik-ui#719) might give more context on the consequences of this issue.

@notcod
Copy link
Contributor

notcod commented Apr 26, 2024

I had that issue because of Cloudflare cache I used. Are you using cloudflare?

@maiieul
Copy link
Collaborator Author

maiieul commented May 17, 2024

@notcod I provided a reproduction that shows this behavior on pnpm preview. But we do encounter a related issue in qwik UI that might be caused by cloudflare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants