New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove header bloat introduced by BestStandardsSupport middleware #8914

Merged
merged 1 commit into from Jan 16, 2013

Conversation

Projects
None yet
5 participants
@nilbus
Contributor

nilbus commented Jan 12, 2013

After the Rails server ran for long enough, Chome started returning a net::ERR_RESPONSE_HEADERS_TOO_BIG error on every page load, and curl would error with curl: (27) Avoided giant realloc for header (max is 102400)!. A server restart would reset the headers and made the problem temporarily go away.

Investigating showed that the same IE=Edge, headers were being appended on every request until finally the header size exceeded the 100k limit that browsers impose.

This patch ensures that the IE=Edge and other header variables only get appended to the X-UA-Compatible header if they are not there already, and it makes the test pass that I modified to catch the problem.

The commit that introduced this problem (d8c1404, @nikitug) was applied to both master and 3-2-stable, so this fix should be backported to 3-2-stable as well.

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jan 12, 2013

Contributor

@carlosantoniodasilva, could you look at this since you originally pulled in the affected code? Thanks!

Contributor

nilbus commented Jan 12, 2013

@carlosantoniodasilva, could you look at this since you originally pulled in the affected code? Thanks!

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 12, 2013

Member

@nilbus thanks, I'll take a look and reply soon.

Member

carlosantoniodasilva commented Jan 12, 2013

@nilbus thanks, I'll take a look and reply soon.

@steveklabnik

View changes

Show outdated Hide outdated actionpack/lib/action_dispatch/middleware/best_standards_support.rb
@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Jan 13, 2013

Member

This obviously needs fixed, yeah.

Member

steveklabnik commented Jan 13, 2013

This obviously needs fixed, yeah.

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jan 13, 2013

Contributor

I was wondering about that too. I'll benchmark and see if I can get the time down if it's significant.

Contributor

nilbus commented Jan 13, 2013

I was wondering about that too. I'll benchmark and see if I can get the time down if it's significant.

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Jan 13, 2013

Member

We decided to remove BestStandardsSupport middleware in favor of config.action_dispatch.default_headers

Member

guilleiguaran commented Jan 13, 2013

We decided to remove BestStandardsSupport middleware in favor of config.action_dispatch.default_headers

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jan 13, 2013

Contributor

@guilleiguaran, when will that happen? Depending on how soon, maybe this should be applied anyway for the mean time.

@steveklabnik, I did some benchmarks using some variants. If I cut out the split/each and just search the original header to see if it contains @header, then it only increases the time 15% instead of 60%.

500,000 repetitions
-------------------
original               0.65483  secs    Fastest
fixed_without_loop     0.773287 secs    15% Slower
fixed_using_index      0.819192 secs    20% Slower
fixed_without_split    1.323478 secs    50% Slower
fixed                  1.640181 secs    60% Slower
Contributor

nilbus commented Jan 13, 2013

@guilleiguaran, when will that happen? Depending on how soon, maybe this should be applied anyway for the mean time.

@steveklabnik, I did some benchmarks using some variants. If I cut out the split/each and just search the original header to see if it contains @header, then it only increases the time 15% instead of 60%.

500,000 repetitions
-------------------
original               0.65483  secs    Fastest
fixed_without_loop     0.773287 secs    15% Slower
fixed_using_index      0.819192 secs    20% Slower
fixed_without_split    1.323478 secs    50% Slower
fixed                  1.640181 secs    60% Slower
@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 16, 2013

Member

Can you please rebase from current master and squash your commits? I'll merge after that, thanks.

Member

carlosantoniodasilva commented Jan 16, 2013

Can you please rebase from current master and squash your commits? I'll merge after that, thanks.

Remove header bloat introduced by BestStandardsSupport middleware
The same headers were being duplicated on every request.
@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jan 16, 2013

Contributor

Squashed and rebased.

Contributor

nilbus commented Jan 16, 2013

Squashed and rebased.

rafaelfranca added a commit that referenced this pull request Jan 16, 2013

Merge pull request #8914 from nilbus/fix-header-bloat
Remove header bloat introduced by BestStandardsSupport middleware

@rafaelfranca rafaelfranca merged commit cfdd5cb into rails:master Jan 16, 2013

rafaelfranca added a commit that referenced this pull request Jan 16, 2013

Merge pull request #8914 from nilbus/fix-header-bloat
Remove header bloat introduced by BestStandardsSupport middleware
Conflicts:
	actionpack/CHANGELOG.md
@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 16, 2013

Member

Thank you

Member

rafaelfranca commented Jan 16, 2013

Thank you

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jan 16, 2013

Contributor

And thanks for the quick response! I'm glad it's fixed.

Contributor

nilbus commented Jan 16, 2013

And thanks for the quick response! I'm glad it's fixed.

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva
Member

carlosantoniodasilva commented Jan 16, 2013

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment