According to the Turbolinks 5 documentation for "Following Redirects" (https://github.com/turbolinks/turbolinks#following-redirects):
When you visit location
/oneand the server redirects you to location/two, you expect the browser’s address bar to display the redirected URL.However, Turbolinks makes requests using
XMLHttpRequest, which transparently follows redirects. There’s no way for Turbolinks to tell whether a request resulted in a redirect without additional cooperation from the server.
And the solution for this is to:
send the
Turbolinks-Locationheader in response to a visit that was redirected, and Turbolinks will replace the browser’s topmost history entry with the value you provide.The Turbolinks Rails engine performs this optimization automatically for non-GET XHR requests that redirect with the
redirect_tohelper.
I have a great interest in using Turbolinks on my Django (1.11) project and I'm wondering if anyone could point me in the right direction of how to create a new Django redirect() function or modify the existing one to always include the Turbolinks-Location header that is needed for redirects to function as expected. I definitely do not want to be manually setting this header every time I do a redirect.
There is a similar entry in the 'Redirecting After a Form Submission' section (https://github.com/turbolinks/turbolinks#redirecting-after-a-form-submission) I would also appreciate any help in understanding how to implement:
If form submission results in a state change on the server that affects cached pages, consider clearing Turbolinks’ cache with
Turbolinks.clearCache().The Turbolinks Rails engine performs this optimization automatically for non-GET XHR requests that redirect with the
redirect_tohelper.
I did see there is a "Drop-in turbolinks implementation for Django" package on github but this is forked from turbolinks-classic and sourcecode has no mentions of the Turbolinks-Location header so I am sure this is not what I'm looking for.