When an HTML document is very large, and it’s updated often, browsers have to re-download the entire document every time. This is very inefficient. Imagine fixing a typo in a 1000-page document. Browsers are re-downloading a file that is 99.999% the same. What a waste of time and resources.
What if the HTML file format supported diffs that would be prepended to the file? So if an HTML document is edited, a diff is generated (think Git) and added to the beginning of the file.
The web server could then stream only the necessary diffs based on the request’s last-visited time, and the browser would reconstruct the HTML document from the received diffs and the original, cached file.
In order to achieve this system today, web developers have to use a service worker. I would love if this was built into the HTML format itself.
The proposal for diff assumes the browser (or a resource management lib) has knowledge of the history and the update itself. While some last state of update info can be retrieved by OPTIONS, browser has to hold the info sufficient to request diff to version. I.e. in addition to old content, the injection range in old and replacement range in new content.
This “patch” kind information can be given back by content owner (CDN, server, package manager, etc.) by special request which is not in the scope of HTML by itself. Rather this is a proposal in HTTP scope.
What is in HTML group scope, the pattern of “patch” as a transformation layer and part of semver support.
Here the “patch” is a compatibility polyfill which would allow to apply the versioned patch content over existing version. This pattern is applicable as to JS modules (usual case in current stack) as to declarative modules( part of Declarative Web Application not yet a proposal).
When module is deployed, its descriptor along with other info( version, dependencies, etc.) could hold the set of version compatibility polyfills along with associated patches those polyfill could use as opposite to load the full content. It is assumed that after old version + polyfill(patch) the content would become identical/compatible with new version full content.
I would be hesitant to support string level patching, rather version recovery step in the transformation pipeline. For such the "patch’ would look like a transformation script. XSLT or DeclarativeCustomElement template for example.
git has proven otherwise. The large repository update is more efficient that get the latest. Of course, there is a balance and efficient way would be computed by loader(browser). The proposal would enable such balanced loading.
This topic interests me a lot, I use an editor called hope.js, which has this feature that you all are talking about in the html. hope.js is inspired by an idea by ted nelson (one of the forerunners of hypertext) - please, see this:source-code or live on
I would be happy if this idea here is a proposal - In part because there is a library that implements this feature, only the service work that uses the library would be missing
With hope.js - you can map the html according to a sequence of characters of beginning and end (It’s similar to git as you want, please see this example):
Now it’s just a matter of creating a service worker with the hope.js library and transmitting the difference in the html changes.
It is not so complex to be done, because there is a library that implements the feature, the data security part maybe using md5 or sha1 is possible on the strings that are modified - (I’m not sure what i’m talking about, but it’s something I thought about now)
With git, you have a backing store that’s a ‘source of truth’ for all revisions of the document. Historically, that’s been uncommon on the general web.
Personally, I’m interested in the idea of an updated delta-encoding spec for HTTP; this has come up a few times, and I suspect some – especially API folks – would benefit from it. We already have PATCH; one could look at this as doing PATCH in the other direction.
However, that doesn’t mean browsers will implement it; they have a pretty high bar for what they work on, and limited resources. That’s going to be the case whether it’s done in HTTP or HTML, however.
Network protocols such as IPFS, Hypercore, Bittorrent have content addressing, perhaps the proposal here allows for content addressing with HTML. Maybe… today this seems to be more common or no. (There are sites for example on IPFS, and things working with Hypercore and linux isos being shared with torrent. Somehow it’s all on the web - just not the html.)
While the partial resource delivery is on HTTP protocol side, the abilities to decide should the resource retrieval use chunk or whole GET reside on browser side.
Browser has sufficient info on what props cached resource has: its checksum, deployment date, etc. Browser can sniff whether resource been changed and during this OPTIONS call can provide its latest available state. The server side would provide whether patch for cached version exist. This flow fits into server-client communication layer. I.e. HTTP.
If you want this proposal be implemented, it has to go to HTTP group first.
Note, the resource is abstract, it is not just HTML. It can be JS, image, web archive or whatever.