halfzebra / create-elm-app

🍃 Create Elm apps with zero configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static assets in public folder not cached for offline usage.

jlengrand opened this issue · comments

Environment

  1. node -v: v8.9.0
  2. npm -v: 6.9.0
  3. npm ls create-elm-app -g (if you haven’t ejected): 2.2.0

Then, specify:

  1. Operating system: Mac OS X
  2. Browser and version (if relevant):

Any really (but mostly tested on latest Chrome

Steps to Reproduce

I have created a simple memory game in Elm.
It uses images listed in the public folder of the repository. I have not changed the config in any way.

I would like my game to be playable offline. However, when starting the application offline no images are present.
All images are referenced in elm via links of this sort : https://github.com/jlengrand/elm-memory/blob/master/src/Main.elm#L334.

When checking in the cache storage, I do indeed see that image network calls do not get cached.
I also see that the static files are not part of the precache files either.

var precacheConfig = [
        ["/index.html", "88788090a3cdc0ee0a40ad22b468112a"],
        ["/static/js/main.644b696c.chunk.js", "da1e9a91968580b340591f0c766bec5e"],
        ["/static/js/runtime~main.1b922744.js", "13a6cba6703084ad6f60a3db941db615"],
        ["/static/js/vendors~main.3ca81432.chunk.js", "86fba34edc08a61c670b6c7527e6b813"]
    ],

Is that an expected behaviour?

To reproduce :

  1. Run the application (https://elm-memory.netlify.com/)
  2. Check the service worker cache storage
  3. See that only the js and html are cached. No static assets
  4. Close application
  5. Switch wifi off
    6 . Start application : No images are present

Game with no assets => https://imgur.com/a/dPS3UcT

Expected Behavior

Images get cached by the service worker and / or get listed as part of the generated precache file.

Actual Behavior

Application is available offline, but none of the images that are not imported in the index.js file are not cached.

Reproducible Demo

Test the demo here : http://elm-memory.netlify.com

Or check in the applications tab and then cache storage.

Specific line of code that uses static assets : https://github.com/jlengrand/elm-memory/blob/master/src/Main.elm#L334

Happy to provide more info if needed. :).

Sorry I just can't get the screenshot to show up :s.

Hi Julien!

Thanks for reporting your issue, very nice example 👍
Let's see if #372 fixes this. Otherwise, I'll investigate it further.

Hello again!

Please check out the latest version, I think the issue should be fixed thanks to changes made by @thepassle in #372 🎉

Please let me know if you will have time to confirm this!

Closing this isssue, please feel free to reopen if you are experiencing caching issues. 👍

Hey, I actually thought this was closed already! Problems all fixed, thanks for the help!