如何检查 apache 是否正在使用“压缩”和“遥远的未来”有效期?

发布于 2024-12-04 21:26:42 字数 2023 浏览 0 评论 0 原文

如何检查我的网络服务器是否正在提供压缩内容以及远期过期标头? YSlow 仍然告诉我,尽管我已将以下项目添加到 .htaccess 文件中,但我的资源正在以纯文本形式发送,并且没有“远期”过期标头:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpg A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType image/ico A2592000
    ExpiresByType image/x-icon A2592000
    ExpiresByType text/css A2592000
    ExpiresByType text/javascript A2592000
</IfModule>

Picture.png

它说需要过期标头的内容之一是 favicon.ico 文件,以下是 Firebug 中列出的标头:

HTTP/1.1 200 OK
Date: Sun, 18 Sep 2011 00:50:03 GMT
Server: Apache
Last-Modified: Tue, 21 Dec 2010 21:47:19 GMT
Etag: "f8233-47e-497f294aba7c0"
Accept-Ranges: bytes
Content-Length: 1150
Cache-Control: max-age=0
Expires: Sun, 18 Sep 2011 00:50:03 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/x-icon

它的资源之一说需要压缩的是主index.php文件,据我所知,它没有发送自己的标头。这是响应标头:

HTTP/1.1 200 OK
Date: Sun, 18 Sep 2011 00:49:33 GMT
Server: Apache
X-Powered-By: PHP/5.3.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=754163feea6fab8a8d6d7f0ef6ed3c29; path=/
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

我正在尝试使用 mod_deflate 因为这是 Apache 2 服务器。

我做错了什么,我可以检查什么,以及如何进一步测试?

它还告诉我“有 17 个组件的 ETag 配置错误” - 也不知道这意味着什么。电子标签位于标题中,对我来说看起来不错。

How can I check and see if my web server is serving up content with compression and far future expires headers? YSlow is still telling me that I have resources that are being sent with plain text and without "far-future" expires headers even though I have added the following items to the .htaccess file:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpg A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType image/ico A2592000
    ExpiresByType image/x-icon A2592000
    ExpiresByType text/css A2592000
    ExpiresByType text/javascript A2592000
</IfModule>

Picture.png

One of the things it says needs a expires header is a favicon.ico file, and here are the headers that are listed in Firebug:

HTTP/1.1 200 OK
Date: Sun, 18 Sep 2011 00:50:03 GMT
Server: Apache
Last-Modified: Tue, 21 Dec 2010 21:47:19 GMT
Etag: "f8233-47e-497f294aba7c0"
Accept-Ranges: bytes
Content-Length: 1150
Cache-Control: max-age=0
Expires: Sun, 18 Sep 2011 00:50:03 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/x-icon

One of the resources it says needs to be gzipped is the main index.php file, which is not sending headers of its own AFAIK. Here is the response header:

HTTP/1.1 200 OK
Date: Sun, 18 Sep 2011 00:49:33 GMT
Server: Apache
X-Powered-By: PHP/5.3.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=754163feea6fab8a8d6d7f0ef6ed3c29; path=/
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

I'm trying to use mod_deflate since this is an Apache 2 server.

What am I doing wrong, what can I check, and how can I test further?

It's also telling me "There are 17 components with misconfigured ETags" - not sure what that means either. The e-tags are in the headers and they look OK to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何时共饮酒 2024-12-11 21:26:42

对于 mod_deflate,我推荐这个测试

For mod_deflate I recommend this test.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文