我刚刚了解了现代浏览器和网络服务器的 gzip 压缩功能。如果我理解正确,服务器会根据浏览器的请求即时压缩。
但是:我在网络服务器上有一些静态的、经过 gzip 压缩的 json 文件。我想简单地发送这些,而不是在每次请求它们时压缩它们。那可能吗?
提前致谢,
米
我刚刚了解了现代浏览器和网络服务器的 gzip 压缩功能。如果我理解正确,服务器会根据浏览器的请求即时压缩。
但是:我在网络服务器上有一些静态的、经过 gzip 压缩的 json 文件。我想简单地发送这些,而不是在每次请求它们时压缩它们。那可能吗?
提前致谢,
米
这是.htaccess,对我有用:
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]
AddEncoding x-gzip .gz
<FilesMatch .*\.htm.gz>
ForceType text/html
</FilesMatch>
<FilesMatch .*\.html.gz>
ForceType text/html
</FilesMatch>
<FilesMatch .*\.css.gz>
ForceType text/css
</FilesMatch>
<FilesMatch .*\.js.gz>
ForceType text/javascript
</FilesMatch>