WebFaction
Community site: login faq

Hi, my site has been up and running fine for about 2 months now, and I have lately been trying to improve its performance with the help of YSlow. So I got a 2 Part question here.

One point YSlow makes is that its best to put all static media on a subdomain on which cookies can be turned off. Currently, all of my static media is served on /media/ with a static app, but I had the idea that there must be some way I can set up http://media.mysite.com to point to http://www.mystite.com/media/. I could then set http://media.mysite.com as my static media domain in django. Is there any way I could do this?

Next, and related to that, is setting up "expires" headers for my static image files. I tried adding this:

ExpiresActive On
ExpiresByType image/png "now plus 365 days"
ExpiresByType image/jpeg "now plus 365 days"
ExpiresByType image/gif "now plus 365 days"
ExpiresByType application/javascript "now plus 365 days"
ExpiresByType application/x-javascript "now plus 365 days"
ExpiresByType text/javascript "now plus 365 days"
ExpiresByType text/css "now plus 365 days"

to the httpd.conf of my django app, but then I remembered that my static files were served with a static app. However, my static app does not have an httpd.conf. How can I set the expires headers for these files?

asked 08 Oct '11, 11:30

germanjoey
526
accept rate: 0%


I don't see any need to point http://media.mysite.com at http://www.mystite.com/media/. You should just need to do this:

  • Add the "media.mysite.com" subdomain
  • Create a new site to serve your static app on that subdomain
  • Set your MEDIA_URL in your Django settings to "http://media.mysite.com/"

Regarding your expires headers, your static-only app is served by Nginx, so you cannot use Apache directives. Instead, you can edit your static-only app in our control panel to set "expires max" in the "extra info" field, and that will be applied to anything served from that app. "expires max" is the only option we support at this time.

Hope that helps!

permanent link

answered 08 Oct '11, 14:44

seanf
12.2k31736
accept rate: 37%

Well, the problem is that while most of my static media is done with django, there are a few places that are hardcoded. I would like it if I didn't have to go and find all of these scattered places. Is there any way to preserve both, like I mentioned in the original question?

(08 Oct '11, 16:10) germanjoey

I also don't see an option to edit my static media app. Do I need to recreate it? Can I delete it without all of my static files being deleted too?

(08 Oct '11, 16:14) germanjoey

Well, the problem is that while most of my static media is done with django, there are a few places that are hardcoded. I would like it if I didn't have to go and find all of these scattered places. Is there any way to preserve both, like I mentioned in the original question?

Sure, you can continue to serve your existing static media app on http://www.mystite.com/media/ while also serving it via a separate site on http://media.mysite.com/ - so, the bits you don't change will still be able to find media at the old location.

I also don't see an option to edit my static media app. Do I need to recreate it? Can I delete it without all of my static files being deleted too?

No, you don't need to re-create it. If you delete it, your static files will be deleted, so don't do that either.

You can edit the app by going to Apps in the control panel and then click the edit icon (the one with the pencil) on the row for whatever app.

(08 Oct '11, 16:20) seanf

Well thanks seanf! I'll give this a try!

(08 Oct '11, 16:23) germanjoey

seanf, I tried creating the subdomain but it seems to 404 on me. Does it take time for the new subdomain to show up?

(08 Oct '11, 17:07) germanjoey

Yes, new subdomains always take a bit of time to propagate. If it's not working after several minutes have passed, then please try flushing your DNS cache as described the bottom of our domain docs and then try again.

(08 Oct '11, 17:34) seanf
showing 5 of 6 show 1 more comments
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:

×128
×123
×10
×9

question asked: 08 Oct '11, 11:30

question was seen: 3,284 times

last updated: 08 Oct '11, 17:34

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 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