hi, Previously I was working on one django project under the domain of abc.com and serving static media files under abc.com/media/. But I realized it would be better to separate my task into 3 different django projects under the subdomains user1.abc.com user2.abc.com and abc.com. my question is, what is the best way to serve the static files(css,js) now? Should I create separate folders for each site and have separate urls pointing to there? Or should I keep store all the files in one url? If so, does it means I cannot use relative path in the url() of my css files? asked 07 Apr '11, 12:49 amateur |
If all the sites are making use of the same set (or nearly the same set) of static media files, then you'd be best off keeping them together. A common pattern would be to make another subdomain called media.abc.com, and serve the static files from the root of this domain. There are some performance advantages to this approach, such as not sending cookies to the media server unnecessarily. If all your static files are served from this one location, then you'll still be able to use relative paths in the URLs of your css files. The only downside to this approach will be if any of your JS files are making AJAX requests to your server. Because javascript files are only allowed to make AJAX calls to servers on the same domain, this approach could end up breaking such calls. answered 07 Apr '11, 13:06 etianen |