Apache2 不发送“内容类型"在标题中 [英] Apache2 not sending "Content-Type" in header

查看:32
本文介绍了Apache2 不发送“内容类型"在标题中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a standard Apache2 installation on Ubuntu.

我试图让 mod_deflate 工作,它确实做到了,但注意到它没有压缩我的 .js 文件.仔细检查后发现 apache 不会为 .php 文件以外的任何内容发送 Content-Type:.对他们来说,它发送的是text/html",这很奇怪,因为 DefaultType 是text/plain".

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."

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

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

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

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

推荐答案

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

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

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

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.

这篇关于Apache2 不发送“内容类型"在标题中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆