WebFaction
Community site: login faq

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
1111416
accept rate: 0%


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.

permanent link

answered 07 Apr '11, 13:06

etianen
112
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×22

question asked: 07 Apr '11, 12:49

question was seen: 4,273 times

last updated: 07 Apr '11, 13:06

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM