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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:50:18+00:00 2026-05-18T03:50:18+00:00

I created a style.css.php file with this code: <?php $gzip = (ob_get_length() === false

  • 0

I created a style.css.php file with this code:

<?php

  $gzip = (ob_get_length() === false && !ini_get("zlib.output_compression") && ini_get("output_handler") != "ob_gzhandler" && extension_loaded("zlib") && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && !headers_sent());

  if(!$gzip) header('Location: style.css');

  header('Content-type: text/css');
  header('Cache-Control: no-cache');
  header('Expires: Mon, 1 Jan 1901 04:20:00 GMT');

  ob_start('ob_gzhandler');

  include "style.css";
?>

What do you think? Is this a good way to compress js/css files? Is there a better way to do this?
I’m doing this for a public app. that can be downloaded by anyone. So there will be people on shared hosts with gzip disabled

  • 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-18T03:50:18+00:00Added an answer on May 18, 2026 at 3:50 am

    No, not OK. There’s a lot of things wrong there. The include, no dying after redirecting, not considering the deflate method, …

    This is very simple to do with PHP, as the zlib output handler automatically detects the appropriate compression to send to the client (if any); all you have to do is enable it:

    <?php
    if (extension_loaded("zlib") && (ini_get("output_handler") != "ob_gzhandler")) {
        ini_set("zlib.output_compression", 1);
    }
    
    readfile('style.css');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created tab style interface using css and javascript with only two tabs
I have created a custom style sheet that overrides the original CSS for my
Following the CSS style trick from this question I was able to create a
I have simple question. I have webdirectory /css and inside is file style.css .
<td width=120 valign=top height=100%> <iframe src=menu.php width=100% height=100% frameborder=0> </iframe> </td> This code always
I intent to create a template PHP file, this template will only serve the
This is the PHP code im using in conjunction with jQuery .ajax to create
I found this article: http://www.deluxeblogtips.com/2010/05/editor-style-wordpress-30.html I created a child theme using the Twentyten theme
I have created two divs in a .css file and then I have linked
So I'm using the following CSS to create a button style; .button { display:

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.