On Tue, 2008-06-17 at 19:55 -0700, Shannon -jj Behrens wrote:
> On Mon, Jun 16, 2008 at 2:37 PM, Cliff Wells <[EMAIL PROTECTED]> wrote:
> > On Mon, 2008-06-16 at 14:26 -0700, Cliff Wells wrote:
> >> On Mon, 2008-06-16 at 13:03 +0200, Wichert Akkerman wrote:
> >> > I am trying to figure out what the best practices for dealing with
> >> > static resources such as CSS, Javascript and images are. With a
> >> > default pylons setup every request goes through two StaticURLParser
> >> > instances and files returned by them do not get any caching headers.
> >> > This is very practical for development but not ideal for a deployment
> >> > For a deployment it would be nice to be able to serve static resources
> >> > from apache or nginx.
> >> >
> >> > How do others do that? Do you use url_for to generate a URL for those
> >> > static resources and have that return a non-paster/pylons URL for
> >> > deployment environments and use the StaticURLParsers when running in
> >> > in development mode? If so, how did you set that up?
> >>
> >> I usually just setup Nginx to handle whatever location my static content
> >> is at. It doesn't matter if Routes is setup to handle that location as
> >> the request never reaches Pylons.
> >
> > Here's an example:
> >
> > server {
> > server_name *.domain.com;
> > listen 1.2.3.4:80;
> >
> > location /public/ {
> > root /var/www/myapp;
> > expires 30d;
> > }
> >
> > location / {
> > proxy_pass http://127.0.0.1:8000$request_uri;
> > include /etc/nginx/proxy.conf; # common settings for proxying
> > }
> > }
> >
> > In this case, any request for, say /public/css/style.css would map to
> > /var/www/myapp/public/css/style.css.
> >
> > Regards,
> > Cliff
>
> I let Nginx handle the URL if such a file exists. Otherwise, I let
> Pylons have a shot at it:
>
> ...
> server {
> listen 80;
> server_name localhost;
>
> location / {
> # Let Nginx handle static content, but proxy to paster for all the
> # dynamic content.
> root /.../wwwaiter/wwwaiter/public;
> if (!-e $request_filename) {
> proxy_pass http://127.0.0.1:5000;
> }
> }
>
> That way I don't have to include "public" in my URLs ;-)
>
> (Of course, including "public" in the URL would probably make life
> easier if I needed to move to something more complicated like a CDN.)
Actually, I tend to use the regex style Jonathon mentioned, but I wanted
the example to be as simple as possible so the solution to the OP's
question would stand out.
Cliff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---