3 ms·
We 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 redirectin
by pavel_lishin 15y ago
We 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.