-1

I plan to host some bootstrap files that need to be updated every 24 hours, maybe more often. I plan to serve the files using nginx, how can I ensure that I only replace files when 0 people are currently downloading them or otherwise detect how many people are currently downloading the content for my own metrics such that I could have an old/ and current/ bootstrap I can swap between when replacement is required.

tsujp
  • 99
  • 2

1 Answers1

1

Use a canonical URL from which you provide a 302 redirect to the URL of the specific version of the file you want to serve at any time. For example:

server {
    ....

    location = /download/file.img {
        return 302 /download/file-v1.3.18.img;
    }
}

Provide a link to /download/file.img to your clients. Whenever you want to change the version, update the nginx configuration and reload nginx.

It doesn't matter if simultaneous downloads exist at the time you make a change. They will continue to completion and new clients will get the new file.

Your log files will show the specific version any client downloaded, and you can use log analysis tools on them.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940