Fork me on GitHub
#perun
<
2017-03-16
>
bhagany00:03:58

I've been looking at gatsbyjs, I think what they're doing probably isn't viable for us...

bhagany00:03:22

they are caching a layout, and then rendering content into it client-side

bhagany00:03:11

and also caching the content source, I think?

bhagany00:03:01

I will look into using the build date as the cache version, but at the moment, I'm not sure how to pass that information to the service worker

bhagany00:03:12

also, I think we will run into a problem because the cache for a page will only be updated after the user visits the page.

bhagany00:03:23

so, in this flow: visit foo.html (v1) -> cache foo.html (v1) -> foo.html gets updated to v2 -> visit foo.html, the version that will be shown is v1

bhagany00:03:01

then, the cache notices that it is stale and gets updated, and the next time the user visits the page it will be v2

bhagany00:03:22

the idea that I had was - always go to the network if it's available, and rely on the server to send a 304 if the content hasn't changed. But, also cache files in the service worker. This way, the site will work offline, but always show the most recent version that the user can access.

bhagany00:03:31

this is a pretty good summary of different caching strategies: https://jeffy.info/2017/01/24/offline-first-for-your-templated-site-part-2.html

bhagany00:03:40

gatsbyjs is using the second option

bhagany01:03:21

also, I am a dork:

podviaznikov07:03:25

I used option 1 (which is full cache). It’s simpler to implement and overhead doesn’t matter much for blogs and simpler sites. But I guess I open also to the “application shell”. We can probably eventually support customization (or different task) to support more variants. So I guess it makes sense to start with the one that is more interesting to you personally. I don’t have opinion on it so far

bhagany12:03:42

I think I like option 1 as well, with the caveat that it probably shouldn't be used for larger sites. But also I think the network should be used if it is available, in preference to the cache, because of the stale content problem.

podviaznikov21:03:57

Yeah, agree. Btw, do you know what is the size of the cache? I saw different strategies for caching. I saw caching only links you opened, or cache entire site in background on first open (that is what I did for my personal site)