Disable caching when serving static files with Nginx (for development)

Since the answer is somehow hidden in the question – here is the solution for nginx in a VirtualBox environment as standalone answer.

In your nginx config (usally /etc/nginx/nginx.conf) or vhost config file change the sendfile parameter to off:

sendfile  off;

While sendfile is at the heart of Nginx’s fame (blazing-fast low-level static file serving efficiency) it might be a bane for local development, e.g. Javascripts that change often and need to be reloaded. Nonetheless Nginx sendfile is smart and probably isn’t most people’s issue; check your browser’s “disable cache” options as well!

Leave a Comment