6

我在 Ubuntu 上安装了标准的 Apache2。

我试图让 mod_deflate 工作,它确实如此,但注意到它没有压缩我的 .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
4

3 回答 3

5

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

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

于 2009-03-11T11:48:20.630 回答
2

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

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

于 2009-03-11T05:11:34.923 回答
0

这是一个已知问题。它是哪个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
于 2009-03-11T04:58:43.627 回答