Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:36:31+00:00 2026-06-02T18:36:31+00:00

I am currently developing an API where size matters: I want the answer to

  • 0

I am currently developing an API where size matters: I want the answer to contain as few bytes as possible. I optimized my JSON answer, but rails still responds with many strange headers

HTTP/1.1 200 OK
Server: nginx/0.7.67                            # Not from Rails, so ok.
Date: Wed, 25 Apr 2012 20:17:21 GMT             # Date does not matter. We use ETag Can I remove this?
ETag: "678ff0c6074b9456832a710a3cab8e22"        # Needed.
Content-Type: application/json; charset=utf-8   # Also needed.
Transfer-Encoding: chunked                      # The alternative would be Content-Length, so ok.
Connection: keep-alive                          # Good, less TCP overhead.
Status: 200 OK                                  # Redundant! How can I remove this?
X-UA-Compatible: IE=Edge,chrome=1               # Completely unneded.
Cache-Control: no-cache                         # Not needed.
X-Request-Id: c468ce87bb6969541c74f6ea761bce27  # Not a real header at all.
X-Runtime: 0.001376                             # Same goes for this
X-Rack-Cache: invalidate, pass                  # And this.

So there are lots of unnecessary HTTP headers. I could filter them in my server (nginx), but is there a way stop this directly in rails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:36:33+00:00Added an answer on June 2, 2026 at 6:36 pm

    You can do this with a piece of Rack middleware. See https://gist.github.com/02c1cc8ce504033d61bf for an example of to do it in one.

    When adding it to your app config, use something like config.middleware.insert_before(ActionDispatch::Static, ::HeaderDelete)

    You want to insert it before whatever the first item in the list that displays when you run rake middleware, which in my case is ActionDispatch::Static.

    http://guides.rubyonrails.org/rails_on_rack.html may be somewhat helpful if you haven’t been exposed to Rack in the Rails context before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're currently developing a site that uses a simple JSON API (RoR) to populate
Currently I am developing an API and within that API I want the signed
I am currently developing a JavaScript add-on which receives JSON from an API. So
I'm currently developing the presentation layer of an android app. The api which I'm
I am currently developing a webpage where I want to use the ToggleClass function
I'm currently developing a component based API that is heavily stateful. The top level
I am currently developing an android application uses Google map API. I am wondering
I am developing a gis application using Google maps API. Currently I am using
Im currently developing an API, and one thing that I decided was to have
I'm currently developing a small REST API for my application. It works fine. There's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.