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?


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

location ~ \.(swf)$ {
    expires -1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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