繁体   English   中英

Apache2 未在 header 中发送“Content-Type”

[英]Apache2 not sending “Content-Type” in header

我在 Ubuntu 上有一个标准的 Apache2 安装。

我试图让 mod_deflate 工作,它确实如此,但注意到它没有压缩 my.js 文件。 仔细检查发现apache 没有发送 Content-Type: 用于除.php 文件之外的任何内容 对他们来说,它发送的是“text/html”,这很奇怪,因为 DefaultType 是“text/plain”。

我不知道这是为什么... mod_mime 已启用,我还没有触及它的配置。

这是我的服务器对 .css 文件的示例响应:

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

看起来这是使用 eTags 缓存项目的结果,而我忽略了这一事实。

发生的事情是这些项目在浏览器缓存中,实际上并不是从服务器发送的,因此没有 Content-Type。 但是,浏览器在对 eTag 进行缓存查找时从服务器接收标头。这就是我所看到的。

当在 httpd.conf 中注释 Content-Type 默认值时,有时会发生这种情况。

我记得在 Ubuntu 8.04 中它设置为 text/html。

这是一个已知问题。 ubuntu是哪个版本?

我刚刚尝试了 ubuntu 8.10 和 debian 5 安装,我还没有触及 apache 配置。 两者都工作正常:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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