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.&nbsp; I could have built in the capabilities necessary to handle this into the CMS, but then I wouldn&#39;t be able to take advantage of the web server-level caching.&nbsp; The nice thing about my solution is that it doesn&#39;t matter what is behind nginx -- it could be a simple site made up of nothing but static files with no app at all.&nbsp; 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">&lt;<a href="mailto:mike503@gmail.com">mike503@gmail.com</a>&gt;</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 &lt;<a href="mailto:nick.pearson@gmail.com">nick.pearson@gmail.com</a>&gt; wrote:<br>
<br>
&gt; While recently working on an iPhone website, I found I had some seemingly<br>
&gt; common requirements but couldn&#39;t find any good write-ups on how to serve<br>
&gt; such a site with nginx. &nbsp;While it&#39;s of course just a &quot;normal&quot; website, I<br>
&gt; wanted to redirect iPhone users to an optimized version of the site while<br>
&gt; still allowing them to get back to the full site if necessary. &nbsp;I also<br>
&gt; needed to serve two versions of the same page from a mobile-optimized<br>
&gt; website for the same URL (an iPhone version and a standard mobile version,<br>
&gt; based on user agent) while allowing each version of the page to be cached<br>
&gt; 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>