perun

Discuss perun static site generator
bhagany 2017-03-16T00:01:58.309322Z

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

bhagany 2017-03-16T00:02:22.313089Z

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

bhagany 2017-03-16T00:03:11.320552Z

and also caching the content source, I think?

bhagany 2017-03-16T00:04:01.328523Z

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

bhagany 2017-03-16T00:06:12.348627Z

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.

bhagany 2017-03-16T00:07:23.359228Z

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

bhagany 2017-03-16T00:08:01.364877Z

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

bhagany 2017-03-16T00:12:22.403152Z

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.

bhagany 2017-03-16T00:17:31.447445Z

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

bhagany 2017-03-16T00:17:40.448828Z

gatsbyjs is using the second option

bhagany 2017-03-16T01:58:21.215209Z

also, I am a dork:

podviaznikov 2017-03-16T07:12:25.014386Z

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

bhagany 2017-03-16T12:45:42.750870Z

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.

podviaznikov 2017-03-16T21:51:57.996582Z

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)