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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:58+00:00 2026-05-25T14:40:58+00:00

I have some CSS and JS files that are dynamically generated by PHP using

  • 0

I have some CSS and JS files that are dynamically generated by PHP using this in my .htaccess:

AddHandler application/x-httpd-php .css .js

And then inside the files, for example:

<?PHP if ($Browser == 'msie') { ?>
.bind('selectstart', function(event) { [...] })
<?PHP } ?>

On the top of them (first line ) i use a conditional get based on Last-Modified header, like this:

<?PHP if (FileIsCached(getlastmod())) die(); ?>

This is the function:

public static function FileIsCached($Timestamp)
{
    $LastModified = substr(date('r', $Timestamp), 0, -5).'GMT';
    $IfModifiedSince = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);

    if (($Semicolon = strrpos($IfModifiedSince, ';')) !== false)
        $IfModifiedSince = substr($IfModifiedSince, 0, $Semicolon);

    header('Last-Modified: '.$LastModified);

    if (!$IfModifiedSince || ($IfModifiedSince != $LastModified))
        return false;

    header('HTTP/1.1 304 Not Modified');

    return true;
}

I don’t need to check encoding because I use automatic gzipping inside my php.ini:

 output_handler = ob_gzhandler

I put them normally inside my index.php like this:

<script type="<?PHP echo $JavascriptMIME; ?>" src="/script.js"></script>

Everything works like a charm… this is my first load response header:

HTTP/1.1 200 OK
Date: Fri, 16 Sep 2011 21:21:51 GMT
Last-Modified: Fri, 16 Sep 2011 19:25:37 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Cache-Control: max-age=31536000, public
Expires: Sat, 15 Sep 2012 21:21:51 GMT
Content-Type: application/javascript
Content-Length: 6161
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

This is my cached response header:

HTTP/1.1 304 Not Modified
Date: Fri, 16 Sep 2011 21:24:39 GMT
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Expires: Sat, 15 Sep 2012 21:24:39 GMT
Cache-Control: max-age=31536000, public
Vary: Accept-Encoding

The problem is that sometimes HTTP data seems to get messed up, maybe by gzipped content or something similar. Chrome network console sometimes show the following error: “Resource interpreted as Other but transferred with MIME type undefined”. Mozilla sometimes makes 2 requests for index.php or try to download it with download prompt. Sometimes file requests stop at 5 when I normally load 7 files and the last downloaded file content is messed up like:

���������ÿÿ���������HTTP/1.1 200 OK
Date: Fri, 16 Sep 2011 19:53:26 GMT
Server: Apache/2.2.17 (Win32) PHP/5.3.6
X-Powered-By: PHP/5.3.6
Cache-Control: must-revalidate, no-cache, no-store, private, public
Cache-Control: max-age=0, max-stale=0, post-check=0, pre-check=0
Expires: Wed, 11 Apr 1984 18:36:00 GMT
Expires: 0
Last-Modified: Fri, 16 Sep 2011 19:53:26 GMT
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Type: application/javascript
Content-Length: 674
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
....

What can it be?

  • 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-25T14:40:58+00:00Added an answer on May 25, 2026 at 2:40 pm

    Try turning the output handler off in PHP and see if things work correctly.

    I found this comment on the php manual page that is probably what you are running into.

    You could try that and if it is the problem, use Apache’s SetOutputFilter to gzip the content for you by adding the following to httpd.conf instead of having PHP doing it

    <Location />
    # Insert filter
    SetOutputFilter DEFLATE
    
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
    # MSIE masquerades as Netscape, but it is fine
    # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    
    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
    # the above regex won't work. You can use the following
    # workaround to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    
    # Don't compress images
    SetEnvIfNoCase Request_URI \
    \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
    </Location>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that uses some css/javascript tabs, they work on my
I have some css files that are deployed in a feature scoped to site
i'm working in an application i have to change some css files in the
I have some html files with their own css. I want to use them
I have a number of .css files spread across some directories. I need to
I have some CSS that doesn't behave correctly with IE8. It works fine with
I have some CSS style that does not work in IE and that works
I have written some CSS which targets elements using the parent > child selector.
I have some questions about basic CSS that I was unable to understand or
Possible Duplicate: Avoiding repeated constants in CSS We have some theme colors that are

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.