I want to use varnish to server static files directly from django, just for benchmarking purposes.
Does varnish support serving static files directly from filesystem?

I'm actually looking for nginx's equivalent "alias" command:

location /media {
       alias    /var/www/djangosite/media;
}
link|improve this question
feedback

2 Answers

up vote 2 down vote accepted

no varnish is a reverse proxy. You sit it in front of say nginx and tell it to cache search file types or pages that have a response header and how to cache it.

link|improve this answer
thanks for the clarification, I'll probably go with lighttpd to serve static files and varnish in front of it to cache them – goldstein Sep 28 '11 at 23:35
feedback

Maybe I'm not understanding your question, but I think what you want to do is pass() certain static file types straight through Varnish to your backend (Nginx, Apache, etc).

We're doing something like that with a static image files that we do not ever want cached using this in VCL_recv():

if (req.url ~ "\.((?i)png|gif|jpg|swf|css|js|ico)$") {
   return (pass);
}

Is that what you're looking for?

link|improve this answer
No, I have varnish in :80 and apache in :8080. All I want is to alias "/media" to "/var/www/django/site/media" just like nginx. – goldstein Sep 28 '11 at 23:30
That's a standard setup with Varnish on 80 and Apache on localhost 8080. Unless there is some subtlety I am missing you could modify my code to match anything with /media (or a longer string if your request URL is predictably longer) in it to return (pass). Something like if (req.url ~ "/media") { return (pass) }. Or maybe I am missing the point altogether. – jdw Sep 29 '11 at 0:03
Oh. Yeah. I get what you're trying to do now. My answer is useless. My bad. – jdw Sep 29 '11 at 0:09
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.