johnbintz/rack-livereload

Script Tag Not Being Injected

Closed this issue · 3 comments

I've followed, so I believe, the straight guidance on getting live reload working, but
the script tag isn't being injected in the head tag. My project is at https://github.com/aedenj/insight.

Try removing Rack::Deflater. By the time Rack::LiveReload gets the output with this setup, it's already compressed. You can then try re-adding Rack::Deflater at the top of the middleware stack.

Yep, that was totally it. Thanks a million!!! Right that's because the middle components execute in the opposite order in which they are added, correct?

Correct! Rack applications and their middleware are a stack, so requests go down from the top, and responses go up from the bottom. Deflater got to the response first and compressed it, so LiveReload got garbage input (in its perspective) and refused to process anything.