4 ms·
This is not a new concept by any means—it’s reviving a concept that has been around since at least the very early days of the web. It’s known as push-based cac
by chrismorgan 7y ago
This is not a new concept by any means—it’s reviving a concept that has been around since at least the very early days of the web.
It’s known as push-based caching, as distinct from pull-based caching.
Push caching: when something changes, you immediately propagate the change to every location, to be valid until replaced. That used to be the standard model. It’s precise, but its eagerness can lead to prohibitive storage requirements (combinatorial explosion is very easy to achieve, and now you must store every computed state, not just the wrapping and the data) and cost of editing if the change has to propagate far (e.g. if you put a list of the five most recent blog posts in a sidebar of a site, making a new blog post now requires that every single page be regenerated). Also it’s conceptually more difficult to get right—doing no caching is far, far easier.
Pull caching: responses are generated on demand and cached for typically a limited time, meaning that you may serve stale data for up to your cache lifetime. But the laziness (that it doesn’t generate everything possible) works in its favour for many situations.
Hybrids are possible. Your cache may have the ability to programmatically invalidate entries, so that if you can calculate which pages would need to be regenerated, you can tell the cache, supplanting time-based caching and potentially yielding the most database-efficient result (no extraneous content generated, but pages cached exactly as long as they will be valid).
Build pipelines like Make are similar: you pull by specifying the resource you require, but its validity is determined by the dependency tree, and the tool essentially pushes things, materialising the necessary resources, until the requested resource is complete.
Push caching has an elegance that pull caching lacks (and I much prefer it, when feasible), but there are reasons why it’s not the standard model of the web any more. It’s tougher to implement well, and has scaling limits that can constrain your design.
----
As a practical application of this: in the article itself, it speaks of the reduced costs and better scaling of the static approach. But it doesn’t take into account the possibility that you generated a bunch of pages that weren’t ever requested (e.g. everyone read the blog post about widgets, but no one opened the list of posts tagged “widgets”, even though you had gone to the trouble of generating it), and so could easily have made more requests than you would have if you had instead had regular pull-based caching in place.
- PaulDavisThe1st 7y agoThere are thousands (millions? billions?) of websites that are not replicated, do not use a CDN, have no multiple locations. When you rebuild the site due to some change, you are updating one single folder heirarchy on one server somewhere. No caching. Just build (and if necessary as a separate step, copy/install). I didn't not see anywhere in his writeup that suggest that you generate pages based on requests.
- chrismorgan 7y agoIf you are modifying HTML directly, no cache is involved. But if you are modifying something that is used to generate the HTML, what you deploy is a complete cache of the operation of building the site. The fact that you could throw it away and build a new version is what makes it match the definition—just because no piece is colloquially known as a cache doesn’t stop it from being just that. Build artefacts are a cache of the operation of compiling the source. To demonstrate this, putting the “requests” part into it: imagine hooking the static site generator up to the server directly, so that a request to /widgets.html turned into “run the static site generator, but only ask it for what it would output for /widgets.html, then respond with that”. The terminology I used is quite correct and widespread in the industry at large—it’s just that it’s not at all in vogue in the JAMstack world.