简体   繁体   中英

Apache2 not sending “Content-Type” in header

I have a standard Apache2 installation on Ubuntu.

I was trying to get mod_deflate to work, which it does, but noticed it was not gzipping my.js files. A closer inspection revealed that apache isn't sending Content-Type: for anything other than.php files . For them it's sending "text/html," which is strange since DefaultType is "text/plain."

I have no clue why this is... mod_mime is enabled and I haven't touched the configs for it.

Here's an example response from my server for a.css file:

Date    Wed, 11 Mar 2009 04:48:12 GMT
Server  Apache/2.2.9 (Ubuntu)
Connection  Keep-Alive
Keep-Alive  timeout=15, max=96
Etag    "30478-4fb-464bec553a600"
Vary    Accept-Encoding

It looks like this was a result of the item being cached using eTags, and my overlooking that fact.

What was happening was that this these items were in the browser cache, and were not actually being sent from the server, thus there was no Content-Type. However, the browser was receiving headers from the server while doing the cache lookup on the eTag.. this is what I was seeing.

This happen some times when Content-Type default value is commented in httpd.conf.

In Ubuntu 8.04 it is set to text/html as I remember.

It's a known problem. Which ubuntu version is it?

I just tried on ubuntu 8.10 and debian 5 installations where I havent touched the apache configuration. Both work fine:

HTTP/1.x 200 OK
Date: Wed, 11 Mar 2009 10:25:17 GMT
Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch mod_wsgi/2.3 Python/2.5.2
Last-Modified: Wed, 11 Mar 2009 10:19:41 GMT
Etag: "1544ae-12-464d534a6c940"
Accept-Ranges: bytes
Content-Length: 18
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM