Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Nginx to serve my static files and proxy dynamic requests to Django. I'd like to cache the static files ("expires 24h;") for all static files except those ending with *.swf.

When I was using Apache, I placed this in the .htaccess file of the directory containing the *.swf files and it worked great:

<FilesMatch "\.(swf)$">
Header set Cache-Control "no-cache"
</FilesMatch>

How can I achieve a similar result in my Nginx config?

share|improve this question
add comment

1 Answer

Using location directive with appropriate regex and with expires directive should work:

location ~ \.(swf)$ {
    expires -1;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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