Spomky-Labs / pwa-bundle

PHP library for generating a full featured PWA manifest
https://pwa.spomky-labs.com
MIT License
29 stars 1 forks source link

Caching core files (e.g. site.webmanifest) #86

Closed tacman closed 2 months ago

tacman commented 3 months ago

Version(s) affected

1.0

Description

When I go offline, most of the files that fail loading are core files, like es-shim-module and site.webmanifest. Also some js files.

The site appears to work okay, so maybe this behavior is expected, especially if it's cache-then-network.

But if there's a way to avoid seeing those errors, it would be easier to find other errors, like assets being incorrectly loaded from unpkg or other site.

How to reproduce

Go to https://noise.survos.com/

refresh, go offline, refresh, open the network tab, sort by status.

Possible Solution

No response

Additional Context

No response

tacman commented 3 months ago

Hmm, something strange is going on, like a short-lived cached or something.

When I run noise.wip locally, after turning off the network I only get a handful of failure. But when it runs on the production server, after one refresh it works, but then a shift-refresh shows lots of .js errors as well.

Maybe .js are treated differently than .css? The js has a hash. Again, maybe this behavior is expected offline.

Spomky commented 2 months ago

Hi,

Indeed, /site.webmanifest and /sw.js could be cached with NetworkFirst or StaleWhileRevalidate strategies. This could be a nice addition.

Regarding the issue with the mp3 file, I think I understand the problem. The files are present in the cache and should be served. I noted the audio player is trying to get the file from the URL /assets/./sounds/WhiteNoise-cf4b8dbe1373cbca5439afb52a01a7ba.mp3. To me the issue comes from the extra ./ in the URL that does not match the cached URL. At line noise-index.html.twig#L30, could you try with {{ asset('sounds/WhiteNoise.mp3') }}?

github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.