I use an on-the-fly asset compacting/concatenating script for my apps, and it works great. The key is to cache the result so that it doesn't become a bottleneck, as Igor pointed out. If you just store the file with the URI that was used to request it (commas and all), then this is as easy as page caching.<br>
<br>So, if a request comes in for:<br><br> /javascript/prototype.js,effects.js,builder.js<br><br>just cache the file at something like:<br><br> [root]/tmp/cache/prototype.js,effects.js,builder.js<br><br>and serve that cached file the way you would any normal, cached HTML file using either try_files or the "old" way of making sure the file exists and rewriting the request.<br>
<br><br><div class="gmail_quote">On Wed, Feb 25, 2009 at 2:00 AM, Igor Sysoev <span dir="ltr"><<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</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 Tue, Feb 24, 2009 at 11:48:39PM -0800, Chris Cortese wrote:<br>
<br>
> So this should be working the same way it does on apache then. $1 looks<br>
> correct from your test. Is there anything else about nginx where it<br>
> would not like the comma?<br>
<br>
</div>No, this should work.<br>
<div class="Ih2E3d"><br>
> Re: combine statically: You mean just putting everything into one js<br>
> file? If so, I guess that's one solution, but it makes for an extra<br>
> step whenever one js component gets updated. Also, different parts of<br>
> the site may need different combinations of js files... meaning more<br>
> work. Before the combinator I was loading files individually, and the<br>
> combinator made some of my pages go from several seconds to ~ 1 second.<br>
<br>
</div>This on-fly combination is good for tens or hundreds requests per second,<br>
but on thousands it will be bottleneck.<br>
<div><div></div><div class="Wj3C7c"><br>
> Igor Sysoev wrote:<br>
> >On Tue, Feb 24, 2009 at 07:15:09PM -0800, Chris Cortese wrote:<br>
> ><br>
> ><br>
> >>In Apache, I use the following rule. It runs the combinator script,<br>
> >>which serializes, minimizes, and gzips a list of javascript files:<br>
> >><br>
> >>RewriteRule ^/javascript/(.*\.js) /combine.php?type=javascript&files=$1<br>
> >><br>
> >>In nginx, I've tried many things, to no avail. Right now I have:<br>
> >><br>
> >>rewrite ^/javascript/(.*\.js)$ /combine.php?type=javascript&files=$1 last;<br>
> >><br>
> >>When I load my page and expand the HTML in firebug, at the place where I<br>
> >>have:<br>
> >><br>
> >><script type="text/javascript"<br>
> >>src="<a href="http://mysite.com/javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js" target="_blank">http://mysite.com/javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js</a>"></script><br>
> >><br>
> >>...it shows me 1 line as follows:<br>
> >><br>
> >>effects.js,builder.js,lightbox_live.js,box.js<br>
> >><br>
> >><br>
> >>Surely wildcards in nginx are greedy right? Can anybody see what's<br>
> >>wrong here?<br>
> >><br>
> ><br>
> >nginx uses PCRE regex library:<br>
> ><br>
> >$pcretest<br>
> >PCRE version 7.6 2008-01-28<br>
> ><br>
> > re> #^/javascript/(.*\.js)$#<br>
> >data><br>
> >/javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js<br>
> > 0: /javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js<br>
> > 1: prototype.js,effects.js,builder.js,lightbox_live.js,box.js<br>
> >data> ^D<br>
> ><br>
> >BTW, I do not think that "the combinator script, which serializes,<br>
> >minimizes, and gzips a list of javascript files" is a good thing.<br>
> ><br>
> >It's much better to combine them statically.<br>
> ><br>
> ><br>
> ><br>
><br>
<br>
</div></div><div><div></div><div class="Wj3C7c">--<br>
Igor Sysoev<br>
<a href="http://sysoev.ru/en/" target="_blank">http://sysoev.ru/en/</a><br>
<br>
</div></div></blockquote></div><br>