【问题标题】:gzipping for faster page loading speedgzipping 加快页面加载速度
【发布时间】:2014-06-10 01:02:14
【问题描述】:

我想压缩我们的网站 www.urbanlocker.co.uk 以加快页面加载速度。我不知道它是 apache web 服务器、lingx 还是如何找出它是哪一个。顺便说一句,我可以访问 filezilla 来上传/下载文件,但不能访问托管公司。我正在复制粘贴这些代码,以便启用 gzipping 并将 .htaccess 文件上传到根文件夹,但没有任何效果。有谁知道我在哪里做错了?

这个是Apache推荐的:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

另一个:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

这个是推荐给nginx的:

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml           application/xml+rss text/javascript;

# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";

# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;

如果您需要更多信息,请告诉我。提前非常感谢。

【问题讨论】:

  • 从 HTTP 标头来看,它是 IIS / ASP.NET,它已经被 gzip 压缩了。
  • Builtwith 是你的朋友:builtwith.com/?q=www.urbanlocker.co.uk
  • @TanHongTat 非常感谢!
  • @jeffatrackaid 谢谢!

标签: apache .htaccess nginx gzip


【解决方案1】:

根据http://builtwith.com,您的服务器是 IIS,它已经在压缩内容。

强烈建议您在开始尝试优化之前了解您使用的服务器类型。

要检查标头和 gzip,您可以使用http://redbot.org/ 之类的工具

【讨论】:

  • 但是当我查看这个网站 whatsmyip.org/http-compression-test 并输入 www.urbanlocker.co.uk 时,它显示我的网站没有被压缩。这让我很困惑。
  • 您可能遇到缓存问题或设置不正确。对于urbanlocker.co.ukurbanlocker.co.uk,我得到了不同的结果。我会和你的主人谈谈,因为这不应该发生。如果使用缓存,则应使用 Vary: Accept-Encoding 标头来缓存非压缩版本和压缩版本。
【解决方案2】:

在命令行上使用 Curl 将返回来自响应服务器的所有标头。此信息通常包含一个“Server”标头,它揭示了正在处理请求的应用程序服务器的类型。

$ curl -I www.urbanlocker.co.uk
HTTP/1.1 200 OK
Content-Length: 19834
Content-Type: text/html
Last-Modified: Mon, 09 Jun 2014 11:40:54 GMT
Accept-Ranges: bytes
ETag: "addd6abd783cf1:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Mon, 09 Jun 2014 17:00:18 GMT

【讨论】:

  • 谢谢,这也有效,但我选择了其他答案,因为它提供了更多信息
猜你喜欢
  • 2021-10-01
  • 2010-12-22
  • 1970-01-01
  • 1970-01-01
  • 2010-12-14
  • 2012-03-15
  • 1970-01-01
  • 2018-02-25
  • 1970-01-01
相关资源
最近更新 更多