网站站长工具中的谷歌站点地图"Compression error"



我们正在创建站点地图XML文件,并在Google网站站长工具中指向它们,它偶尔会向某些文件提供以下错误消息:

压缩错误

Google文档中的"如何修复"并没有真正给出任何可能出错的提示。

该文件在.NET中生成,并使用System.IO.Compression.GZipStream和MSDN推荐的使用方式进行压缩。

当我们以 7-zip 打开文件并重新保存文件而不进行任何更改时,它确实有效

有什么提示吗?

好的,这是我对这个问题的看法。很明显,System.IO.Compression.GZipStream生成的文件没有损坏,但仍然存在小问题,不喜欢Google。

Strightforward的解决方案和检查是切换到其他压缩库,看看是否有帮助。

更复杂的解决方案是对GZIP文件格式规范进行严格检查。具体来说,我会检查(比较)文件的标题(原始文件和 7zip)。这样,您可能会发现文件有问题,并可能修复它。

+1 表示@Akash的答案。 我在尝试访问压缩内容时在 IIS(尤其是 IIS 6)中遇到问题。 让IIS进行压缩,只需将未压缩的xml文件放在方便的位置即可。

如果您可以访问.htaccess文件,那么我会为您提供一些编辑它的提示,并让您的所有文件将自动缓存和压缩。好的,这是放入包含.htaccess文件的网站根目录中的提示。

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch ".(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>
# compress text, html, javascript, css, xml:
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

您可以查看您的站点地图是否会被压缩,而不是通过某些工具(如 woorank.com),它将显示是的,您的网站利用了 Gzip 的优势,是的,当 Google 抓取您的站点地图和上述代码中包含的任何其他文件时,它会自动完成

最新更新