WebFaction
Community site: login faq

I followed this recipe to create a static app: http://forum.webfaction.com/viewtopic.php?id=2594

I created a subdomain static.mysite.com

I created a static app.

I created a website static, which puts those two together.

(I did the other stuff, too)

I tried testing it by writing static.mysite.com in the url. The site cannot be found. If the site has been created then this should work, right? I have also done the other stuff, creating the symlink, etc. The image files are not found.

asked 18 Nov '12, 07:03

tpip
4111321
accept rate: 0%

The above link is a bit old, before Django added static media along side of media. Here is our documentation on Serving Django Static Media. If you are still having a problem, please open a ticket at our support site, and we'll help you find the cause of the issue.

(18 Nov '12, 07:34) timg ♦♦

I'm reading through those directions. The last step is "Collect the static media into the static media application." Does that mean that there will be two copies of every file? What if I make a new one, where do I need to put it? My users will be uploading image files, which will them be displayed in the webpage. What directory should these be uploaded to in order for this static app to work?

(18 Nov '12, 08:53) tpip

Yes the collectstatic will collect all the files into one central location. If you make a new file you will put in the same location as your others and run the collectstatic command again to collect to the static location set in your settings.py.

STATIC is used for JavaScript, CSS, etc. and MEDIA is used for user-generated content - uploaded images and files. This means user created content is not handled by collectstatic.

Check out the official documentation on Managing static files.

(18 Nov '12, 09:12) timg ♦♦

But is there then another solution for user-generated image files?

(18 Nov '12, 13:23) tpip

Yes, user generated images and content are handled through media, not static.

(18 Nov '12, 13:28) timg ♦♦

I am using that solution for media, but this means that media is being handled through my regular Django app. I have seen references to creating static apps for "static media". One such reference is the page that I linked to in my question. I thought that the point of using a separate app was to make the site faster and use less memory. Is that not correct? If it is correct, how do I get those same benefits with user uploaded images? If it's not correct, then what is the point of having a separate app to handle static stuff? (timg, do you work for Webfaction - are these "official" webfaction answers? Thanks!)

(19 Nov '12, 01:52) tpip

You can still serve user-uploaded images via Nginx if you like - just create a new "Symbolic Link to Static-Only" application and point it (in the extra_info field) to the location where your media files are stored. Then, mount that new application on your website record in such a way that existing requests for those media files must pass through your new Symbolic Link application. (The exact URL Path to use depends on the existing URLs for static media, but the concept is the same as for Static Media at /static).

Also, yes - Tim G. works for WebFaction, so these answers can be considered authoritative.

(19 Nov '12, 03:05) ryans ♦♦

Alright, I did what ryans suggested and it seems to work. So far, so good. However, a main reason for setting up a static app is to be able to set the expiry date. I would like for the media files to be cached as long as possible. Can I do that with "Symbolic Link to Static-Only"? And, if not, is there a way to create a static app to serve user-uploaded images, which also sets an expiry header?

(02 Jan '13, 09:28) tpip

Can I do that with "Symbolic Link to Static-Only"?

No, the static-only symlink app doesn't let you adjust headers.

And, if not, is there a way to create a static app to serve user-uploaded images, which also sets an expiry header?

Yes, create a static-only app (not a symlink app), including "expires max" in the extra info field when you create the app. After you've created the app, copy your static media over to it, then serve the app on whatever domain or URL path you need it on.

(02 Jan '13, 10:50) seanf
showing 5 of 9 show 4 more comments
Be the first one to answer this question!
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:

×125

question asked: 18 Nov '12, 07:03

question was seen: 2,662 times

last updated: 02 Jan '13, 10:50

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