Force download a file on page load
The {% header %} tag probably isn't what you want then - they must be rendered first, as they affect what the webserver is returning to the browser in the page headers. Because you're setting the location header to the file url, it is telling the browser to redirect to that instead of rendering the rest of the page (which would still technically be rendered by the server, just never seen by the browser).

It sounds like the better option would be to trigger the redirect to the file location via javascript after the page loads, similar to this approach.