4 ms·
I disagree entirely. Trying to make a cache anything other than a cache is a fatal error. The purpose of a cache is to return exactly what would have been retur
by jerf 15y ago
I disagree entirely. Trying to make a cache anything other than a cache is a fatal error. The purpose of a cache is to return exactly what would have been returned if the cache wasn't there, only faster, and even minor deviations from that principle rapidly become problematic. The gulf between disposable data that can be optionally used for speeding things up, and canonical copies of data (even locally canonical ones) is not a difference that should be glossed over into one single subsystem, but a difference that should be highlighted and called out and generally fussed over.
For that matter, the W3C should stop calling this a "cache". The offline applications, as specified, are not functioning like cached values. They are functioning like installed applications. If you can't dispose of a "cache" without a thought beyond "Gosh, my app's performance is going to suffer until this cache is repopulated", you are asking for pain, or, alternately, you don't actually have a cache.
To the extent that you may be able to re-use HTTP mechanisms for detecting changes, that's great, but it should be done carefully and consciously to avoid dependencies between the cache and application storage.
Also, I don't see how this secondary proposal deals with the fact that an application install may involve installing files that the browser has not accessed yet, which seems a fatal error to me.
- AffableSpatula 15y agoThere's not a fatal error there, afaik. I didn't detail how to deal with un-accessed files because the solution seemed trivial: when your application boots up, make sure it prefetches all required assets (i.e. warms the cache) by making ajax requests to each URL. I'm not sure about your interpretation of what does and doesn't constitute appropriate use of a web cache, either. Do you have any examples of the kind of problem you're foreseeing?
- jerf 15y ago"I'm not sure about your interpretation of what does and doesn't constitute appropriate use of a web cache," Not web cache, just plain cache cache. Any kind of cache. Trying to abstract cached content and permanent content with one abstraction is a recipe for disaster, a disaster that leaves you without the proper tools to solve it. It's the sort of disaster that comes up a lot in software engineering where I can not provide a single pithy code example in 20 lines, because they you can always reply with "Well, I'd just write these 25 other lines". The problem is deeper; you've written a semantic confusion into the base primitives of your system and you will pay for it. It's similar to the problem with RPC; you should not and can not simply sweep the difference between local and network communication under the rug. It works small and is incredibly painful in the large. Unfortunately, I can not seem to find a pithy explanation of why this is true. (Perhaps I should write one.) An installed application is not simply a cached version of the website. Even the W3C proposal has gone too far down that road, but the solution is not to keep going even farther.
- deleted 15y ago[deleted]
- johnzabroski 15y ago> It's similar to the problem with RPC; you should not and can not simply sweep the difference between local and network communication under the rug. It works small and is incredibly painful in the large. Unfortunately, I can not seem to find a pithy explanation of why this is true. (Perhaps I should write one.) I would be willing to help you write it if you'd like. I understand network disruption, partial failure, and weak/episodic connectivity very well, including scenarios where nodes in a network are required to remain radio-silent for long periods of time. Command-and-control military-style systems are much more general than the Web. Related, automatic code distribution is a sort of Holy Grail in programming language design. It is difficult for many reasons. Even data is a huge problem. For example, if the toolbar buttons on Google Docs suddenly die (like they did for our marketing rep a few weeks ago), then the application can become extremely hard to use. Web applications don't handle this well today, and a cache doesn't really address this well, either, because it could be that the new resource invalidates an older cache. In other words, it is a version control and configuration management problem.
- bad_user 15y agoSo to "warm the cache" you're basically going to have a list of files that need to be prefetched. Also, in case the network is offline, you need fallbacks for certain unavailable resources. So why not have a standard mechanism for this that doesn't clutter the HTTP protocol? There is a difference between Cache-Control and this offline-cache ... Cache-Control specifies an expiry date (that has to make sense even if you're permanently online, as in you can't put an expiry of 1 month if articles may be updated in far less than that), while the offline cache gets invalidated only when you update the manifest and thus provides an easier to deal with mechanism for the distribution of new versions. I agree with the above comment that you can't really abstract offline away. Offline is offline. People may stay offline from a couple of hours to a whole month and your app has to still function in that period of time - think of Google Reader - personally I like having favorite articles copied locally when I'm going on vacation, but roaming costs are too much for my data plan and I'm definitely turning the net off. So the app has to cache these articles for an indefinite period, but it has to update as soon as I get online (preferably only things that got updated).
- AffableSpatula 15y agoYour app should already have fallbacks for 'certain unavailable resources'. I don't think this does clutter the HTTP, in fact the proposal even provides an alternative to the one single addition it does make to HTTP. I'm not clear on the other points you've made, sorry
- Peaker 15y agoI think that the terminology you use is very different from the standard one. > If you can't dispose of a "cache" without a thought beyond "Gosh, my app's performance is going to suffer until this cache is repopulated" According to what you're saying: "Write cache" or "dirty cache" are oxymorons, and yet these terms are used everywhere.
- jerf 15y agoYou didn't finish my quote, and the the part you cut off is not incidental: "you are asking for pain". Many things at hardware level are indeed asking for pain. That smart people have labored at length to make them work anyhow doesn't mean it wasn't quite painful. I didn't say it was impossible. For hardware, it can be a sensible tradeoff. For a generalized web application installation method I don't think it is; it writes into the standard that you must know a lot of very subtle things that your average programmer doesn't even see as issues. This is a bad thing to put into a standard. Better to do something stupider-but-easier, and let people get clever if they think they have some compelling need. Though stepping one "why" back, the real problem here is that the W3C shouldn't be trying to prospectively write a standard this complicated at all. Why they keep doing that and why people care when they do is beyond me, their track record for creating standards de novo is terrible. This really does call for a few browsers to just try some stuff and see what sticks, no matter how "proprietary" it may make the solution, because no group of people is smart enough to solve all the problems that arise here without even a quarter of an implementation in hand somewhere.
- Peaker 15y agoNot just hardware. Kernel file systems and block devices have write caches. Storage systems have write caching. It is a pretty important mechanism, and may or may not be painful depending on reliability requirements.
- johnzabroski 15y agoI agree, but am not sure for the exact reasons you state. Put simply, offline applications need to support partial failure. The author of this article seems to want to write web apps without having to have much concern for partial failure. That is my own summary and take-away. If you agree, then we are on the same page. Not dealing with partial failure means succombing to Fallacies of Distributed Computing - period. I wouldn't even trust the browser to do atomic swaps of cache', anyway, and I wouldn't even want to think about what that code would look like, or what the spec for the author's ideal would look like. Bottom line: The author is defining words like "brittle" from one perspective only. What he wants is probably better provided by a library on top of caching. Moreover, I shriek at the idea of an application having to know its "size". That exposes the representation of the resource.
- johnzabroski 15y agoA good early example of handling partial failure is the Zimbra mail & calendar app, the original "AJAX" app on the Internet, before Gmail/Google Calendar even. The Zimbra WebGUI supported an explicit "serverless" mode, which allowed for saving things like outgoing e-mail to a local repository and then, when network availability is detected, re-synchronize with the server and transparently transition to "server" mode.