On Jun 17, 6:36 pm, Wichert Akkerman <[EMAIL PROTECTED]> wrote:
> Previously 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.
>
> How do you do that during development? Do you hardcode /public/ paths
> for static resources everywhere?
>
> I'm starting to think that a best practice setup is something like:
>
> - instead of dumping static resources in / as currently done always
>   put the in a private place, similar to how webhelper put its
>   javascript files in /javascript/
>
> - setup a separate route for static resources and always use url_for to
>   them. I'm not entirely sure routes supports this at the moment.
>
> - setup a URLMap in development.ini so you can run the whole site with
>   just paster
>
> - for production use a dedicated webserver to serve resources, possibly
>   running on another host(name) even

When using mod_wsgi, which based on other thread you are, and using
just Apache and no other separate media server, for development use
whatever mechanism Pylons supports. Then in production simply add an
Apache 'Alias' directive for the same URL as static files served by
Pylons, with Alias directive referring to directory where Pylons
serving them from. Will also need to create Directory directive in
Apache to allow Apache to serve files in that directory.

In other words, you don't need to change Pylons application for
production usage, just have Apache intercept just that URL subset
where static files appear.

See section 'Hosting Of Static Files' of:

  http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

Even if using separate media server/proxy with Pylons application
sitting behind proxy rather than embedded in server, the server should
allow such interception of overlapped URL subset.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to