9 ms·
Application Cache Is A Douchebag
- simonw 14y agoJake based this article on the work he did on our offline HTML5 mobile app ( http://m.lanyrd.com/ http://m.lanyrd.com/ ) - doing offline right is surprisingly trick and full of edge cases, and I haven't seen them documented in as much detail anywhere else.
- Joeri 14y agohttp://appcachefacts.info/ http://appcachefacts.info/ contains most of the gotcha's.
- pavel_lishin 14y ago> GOTCHA #8: REDIRECTS TO OTHER DOMAINS ARE TREATED AS FAILURES So are redirects to your own domain, though not quite the same as here. What it means that while downloading the resources specified in your manifest file, encountering a 302 means that the entire applicationCache fails. Downloaded 99 static files fine, and then get a 302? Congratulations, your cache is now invalid. > GOTCHA #9: AN EXTRA HOOP TO JUMP THROUGH FOR XHR > You can make XHR requests to cached resources while offline, unfortunately older versions of WebKit finish the request with a statusCode of 0, which popular libraries interpret as a failure. Not that much older. This is the case for iOS5.1, the last time I checked, and for every Android phone I've tested this on as well.
- jaffathecake 14y agoYeah, redirects to manifest entries makes the cache fail, but a 302 on a page the user visits (which is covered by a FALLBACK rule) is fine as long as it's to the same domain. As for GOTCHA #9, I thought that was fixed in iOS4. But yeah also fails on Blackberry playbook and Andorid 3 & 4. Actually works on Android 2.3 (unless I'm mistaken), which isn't suprising as there are loads of regressions in the Android 3 browser.
- pavel_lishin 14y agoWe do mobile web development, and we like to scale down images to the appropriate size for any given phone. I was hoping to be clever, and instead of redirecting every user to a hardcoded image path (/illustration.17.503x302.jpg), to just redirect them to /illustration/17 - which would generate the properly sized image, and use a redirect to display it. Spent a few days on it. Worked great online. Then I discovered that putting /illustration/17 in the cache manifest made the entire thing fail, since it's a redirect. C'est la days of wasted work.
- sk5t 14y agoWell, why not return the proper content right away instead of redirecting? 'Course, you'd have to mark it with a private cache policy to prevent caching proxies from weirding things up.
- pavel_lishin 14y agoBecause then I'd have to open an image in PHP just to output it right back out. More work than just having Apache serve it.
- cstejerean 14y agoYou can use X-SendFile (or X-AccelRedirect) to have your PHP code tell Apache or Nginx which image to serve, without having to send a 302 to the browser.
- jaffathecake 14y agoBah. Nice idea though. So far we're using a double-sized sprite image whether you're on a high dpi device or not. Thankfully everything that supports appcache supports background-size, and the 'waste' of serving high-res sprites to phones that couldn't use them was negligible (it's basically just http://static.lanyrd.net/css/mobile-web/img/sprites5@2x.53a3a8cb.png http://static.lanyrd.net/css/mobile-web/img/sprites5@2x.53a3...).
- BoxPwn 14y agoDo you KNOW what a douchebag is? It's for women. More sexist BS from the brogrammers!
- peterwwillis 14y agoYes, that’s right, I verbified “offline.” Yes, I verbified “verb.” Feel free to inbox me grammar complaints that I’ll trashinate. I think more worders should matriculate into the Strongbad School of Verbinizin' Speechy Things.
- ericclemmons 14y agoI was going to comment on the same line! It's very easy for articles like this to come across dry, but writing that lets the author's wit shine through helps pacing significantly, almost like comic relief after a tense moment.
- parfe 14y agoSweet, let's unabashedly support more sexism! That's what the tech industry needs. Somehow, an article describing caching of web applications manages to denigrate women, for no reason. The underrepresentation of women in tech is caused by this mindless sexism, like body-shaming women. Douche bag is a sexist insult. You're insulting your target by associating them with feminine care products. It's a direct associating between "This thing is womanly so it is bad." Even after several other stories these digs at women still get publicized!
- mediocregopher 14y agoBased on your argument, calling someone a dick would be sexist as well. I'm not arguing that the author is right to use douchebag; he was trying for entertainment value but to me it came across as unnecessary. But getting worked up because he chose the wrong insult out of the many, many insults we have relating to both male and female body parts and functions is silly. Calling someone a douchebag doesn't insult anyone else who uses a douche the same way calling someone a dick doesn't bother me everytime I use the restroom.
- parfe 14y agoBased on your argument, calling someone a dick would be sexist as well I reread my comment and I didn't call anyone a dick. I checked the article and it doesn't use dick either. I suppose you're after some false equivocation here which means you don't quite understand how women are being actively repelled from the tech industry. Using language hostile to a minority group is exclusionary. "Dick" as an insult in a male dominated group is not. I'm not arguing that the author is right to use douchebag; he was trying for entertainment value but to me it came across as unnecessary. But getting worked up because he chose the wrong insult out of the many, many insults we have relating to both male and female body parts and functions is silly. It's the only way to encourage positive change. I see you'd prefer to ignore it, but that just perpetuates the hostile culture that has ingrained itself over decades. He could have gone with anything (asshole for instance!) but chose to Other women and likely not intentionally, which is still no excuse. You are free to ignore the sexism just as much as you were free to ignore my comment, but for some reason you decided to step in and defend the article from my negative rated comment.
- Joeri 14y agoAppcache is an app packaging mechanism, and should be treated as such. The manifest is the equivalent of a plist or xml file describing the app package. It actually makes a lot of sense when you view it like that. By extension, you should only put stuff into appcache that you would put in a native app bundle. I've built an appcache app that is a bunch of static javascript (in the CACHED section) contacting a bunch of services in the NETWORK section. There is no FALLBACK section, because any resource is either online or offline, but never both. The UI is designed so the user knows which content is online, and can decide for themselves if they have good enough connectivity. Dynamic content goes into localstorage if it needs to be persisted. This way of using appcache works very well and is mostly painless.
- logjam 14y agoMale here. Most professionals will no longer bother to read an article with a headline that uses insulting, sexist words. If you worked for me and wrote that title for an article about something we were working on, you wouldn't work for me any more. Period. Tech culture is moving away from childishness, and there were a large number of other words you could have used in your title. Go learn some.
- peterwwillis 14y agoAlso male here. 5'6. Brown/blue/red hair. Skinny. I agree that these words have no place in a professional working environment. But I still read articles with bad words. (Actually, it's why I clicked on it in the first place!)
- Mz 14y agoI actually upvoted both of you -- I mean I upvoted your long list of swear words and point that they are intended to offend and also upvoted his point that they don't really have a place in a headline. I swear like a sailor IRL but I try to keep most of my online remarks pg-13-ish. It seems rude/ disrespectful and a good way to lose part of the audience to be unnecessarily crude. Just my take.
- lbotos 14y agoI oftentimes volunteer at my local high school with the web development classes and always make it a point to direct the students to review alistapart as they have excellent articles. I've always assumed alistapart had editors that keep the content top notch and "accessible". I was surprised this morning to see this title was real. I'm not pretending like American high schoolers don't use this kind of language but seeing it in a highly respected "magazine" of sorts made me squirm. I'm glad I wasn't in a classroom this morning.
- Mz 14y agoYes, it is something I have thought about quite a lot and concluded that being too prissy tends to not have broad appeal but being unnecessarily crude is just stupid if you are trying to grow an audience. I have fantasies of doing a web comic at some point. Should that ever work out, the standard I have in mind is that it should be "Night Court"-esque in nature. In spite of frequently having "adult" themes it was implicit, not explicit, in nature. My 24 year old son has said that when he watched "Night Court" as a child, he thought Dan was some loser who talked a lot of crap but saw almost no action. When he saw the same show when he was older, he was surprised to realize that wasn't the case at all. Why was he even able to make the comparison? Because the show was acceptably "clean" that I did not hesitate to let a young child watch it. That translates to a much larger potential audience than the "adults only" material. Besides, I taught my sons from an early age that swearing was not "adult" behavior but was simply rude: http://www.kidslikemine.com/manners.shtml http://www.kidslikemine.com/manners.shtml
- saurik 14y ago> GOTCHA #3: THE APPLICATIONCACHE IS AN ADDITIONAL CACHE, NOT AT ALTERNATIVE ONE This section is not quite true, at least for WebKit. This article states that the application cache will use the normal browser cache when making outgoing requests, honoring whatever cache control headers were sent by the server. What actually happens is that the browser always forces a revalidation of the content with the server, regardless of what the cache control headers that had been served. Now, I certainly /wish/ it were the case that it honored the normal browser cache, but it simply doesn't. The result is that the application cache makes these outgoing requests painfully and arduously one-at-a-time, waiting for the previous one to entirely complete before making the next one... over a mobile data connection this takes /forever/, and it is quite possible that it simply does not finish by the time the process is aborted by one of these needless server requests failing or the window being closed. Normally, you can mitigate these issues by sending files with "cache this effectively forever" headers and always using unique filenames, but with the application cache manifest system (which you are going to be using to support guaranteed-consisten offline operation) you are forced to wait for every request to resubmit before seeing the update. Here is the code from WebKit's ApplicationCacheGroup.cpp, where you can see "max-age=0" being sent as Cache-Control for the outgoing requests. (Sending that header as a user-agent serves to "force any intermediate caches to validate their copies directly with the origin server", per RFC2616). PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KURL& url, ApplicationCacheResource* newestCachedResource) { ResourceRequest request(url); m_frame->loader()->applyUserAgent(request); request.setHTTPHeaderField("Cache-Control", "max-age=0");
- jaffathecake 14y agoI don't think this is the case, not in Chrome anyway. See http://www.youtube.com/watch?v=q7QL0NAwES8 http://www.youtube.com/watch?v=q7QL0NAwES8 - All files are "must-revalidate" except the JS file which is far-future cached. When the manifest is changed an update is triggered, all files are updated except the JS file, which is assumed to be fresh because of the far future expiry. You see similar behaviour when no caching headers are served, heuristics take over & files may be updated from the normal browser cache rather than going to the server.
- Throlkim 14y agoInteresting read and nicely written. It's just a shame HN doesn't have a 'report' feature like Reddit, as I can't report all the whiners in this thread as douchebags.