The reason I did this at the web server level rather than at the application level is that the Rails app I have running behind nginx is a generalized content management system. I could have built in the capabilities necessary to handle this into the CMS, but then I wouldn't be able to take advantage of the web server-level caching. The nice thing about my solution is that it doesn't matter what is behind nginx -- it could be a simple site made up of nothing but static files with no app at all. It was this simplicity (and ignorance on the part of the app) that I was going for.<br>
<br><div class="gmail_quote">On Mon, Jan 12, 2009 at 4:40 PM, mike <span dir="ltr"><<a href="mailto:mike503@gmail.com">mike503@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Mon, Jan 12, 2009 at 2:19 PM, Nick Pearson <<a href="mailto:nick.pearson@gmail.com">nick.pearson@gmail.com</a>> wrote:<br>
<br>
> While recently working on an iPhone website, I found I had some seemingly<br>
> common requirements but couldn't find any good write-ups on how to serve<br>
> such a site with nginx. While it's of course just a "normal" website, I<br>
> wanted to redirect iPhone users to an optimized version of the site while<br>
> still allowing them to get back to the full site if necessary. I also<br>
> needed to serve two versions of the same page from a mobile-optimized<br>
> website for the same URL (an iPhone version and a standard mobile version,<br>
> based on user agent) while allowing each version of the page to be cached<br>
> independently.<br>
<br>
</div>I would just do this in the application (PHP, etc.) level.<br>
<br>
You could in theory do something funky with user agents in nginx and<br>
do some rewrites or proxy to something else, or try to leverage the<br>
XSL/XML capabilities nginx has. Otherwise I see no reason for nginx to<br>
be invovled in this and would suggest to everyone to do this kind of<br>
work in the application layer.<br>
<br>
</blockquote></div><br>