Skip to content
This repository was archived by the owner on Jul 28, 2018. It is now read-only.

Parameter for Custom Headers #610

Open
Naomarik opened this issue Sep 14, 2015 · 0 comments
Open

Parameter for Custom Headers #610

Naomarik opened this issue Sep 14, 2015 · 0 comments

Comments

@Naomarik
Copy link

I'm not entirely sure if this is desired following sentiment of the discussion here: #515

I've hacked it in myself

Turbolinks.visit(url, change: ['search_page'], header: { key: 'X-Render-Partial', value: 'search_page'})

In the fetchReplacement method

xhr.setRequestHeader 'X-XHR-Referer', referer
# Under this line
if options.header
  xhr.setRequestHeader options.header.key, options.header.value

And this lets me call this.

if partial = request.headers['X-Render-Partial']
  render partial: partial, layout: false and return
end

This has allowed me to whittle my views render time from ~500ms...

image

...to ~55ms for the same query by avoiding the layout rendering and choosing the exact partial to render.

image

Causing my app to be the fastest thing I've ever seen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant