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 6575891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:26:35+00:00 2026-05-25T15:26:35+00:00

I have some serious (or better say: strange ) issues with the HTTP-header: Content-Encoding.

  • 0

I have some serious (or better say: strange) issues with the HTTP-header: Content-Encoding.

I want to gzip my content before sending it to the clients browser. For this I am checking if the clients browser accepts gzip and if so I am using ob_start("ob_gzhandler") and setting the content-encoding: $response->addHeader("Content-Encoding", "gzip");

  • I think my problem is the manual setting of the Content-Encoding header.
    If I use $response->addHeader("Content-Encoding", "gzip"); the content is only shown in Opera.

  • If I use $response->addHeader("Content-Encoding", "'gzip'"); the content is shown correct in all browsers, but gzip compression checks say that it is not compressed and the W3C HTML Validation service cannot encode the page:

The error was: Don’t know how to decode Content-Encoding ”gzip”

  • If I don’t use the line and online use ob_start("ob_gzhandler") the page can only be shown in opera

My complete lines of code, which does correct output in browser is following:

$accEncoding = $request->getHeader("http_accept_encoding");
if($accEncoding !== NULL && substr_count($accEncoding, 'gzip')) {
    ob_start("ob_gzhandler");
    $response->addHeader("Content-Encoding", "'gzip'");
    $response->addHeader("Vary", "Accept-Encoding");
} else {
    ob_start();
}

Am I using the ob_gzhandler wrong or am I doing any other mistake here? I am very confused about the correct handling of gzip output.

  • 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-05-25T15:26:35+00:00Added an answer on May 25, 2026 at 3:26 pm

    ob_gzhandler already verifies that the browser supports gzip compression:

    Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept (“gzip”, “deflate” or none at all) and will return its output accordingly.

    It also sets the Content-Encoding header accordingly.

    Also note that using zlib.output_compression is preferred over ob_gzhandler().

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

Sidebar

Related Questions

I have some serious issues deploying my rails 3 app. There isn't a post
I have a solution with multiple projects and we need to do some serious
In a desktop application needing some serious re-factoring, I have several chunks of code
I have some kind of test data and want to create a unit test
I have a serious long else if statement which contains some links and some
Whenever I have some records/objects that I want to be in a certain order,
I have a query which is taking some serious time to execute on anything
I have done some simple OpenGL (old fixed pipeline ,without shaders ..etc) and want
I have a View Model that has some serious nesting. I need to populate
I have done some really serious refactoring of my text editor. Now there is

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.