Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"

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

share|improve this question

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

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

Your Answer


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.