3 ms·
> 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 whil
by pavel_lishin 15y 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 15y 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 15y 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 15y 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 15y 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 15y 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 15y 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...).
- pavel_lishin 15y agoMost of the images we serve are loaded from a different server, and can be dynamically changed by editors, etc. Putting them into a sprite would probably be more work than it's worth.