标签: deflate

Apache mod_deflate不压缩json输出

我已经按照多个教程中的所有步骤在Apache中启用mod_deflate但是当我向本地Web服务器发出json(通过PHP脚本)请求时,我仍然没有看到压缩(在Fiddler中).我的浏览器不需要压缩到localhost,但我的机器会定期通过慢速VPN暴露,所以我想使用它.

来自httpd.conf:

LoadModule deflate_module modules/mod_deflate.so (没有注释掉)

mod_deflate.so存在于Apache2/modules中

PHP脚本在运行时立即设置以下标头: header('Content-Type: application/json');

application/json 存在于Apache2/conf/mime.types中

这是httpd.conf中关于应该压缩的mime类型的相关部分:

Alias /mapguide "C:/Program Files/OSGeo/MapGuide/Web/www/"
<Directory "C:/Program Files/OSGeo/MapGuide/Web/www/">
  AllowOverride All
  Options All -Indexes
  Order allow,deny
  Allow from all

...

  # Content compression
  AddType text/javascript js jgz
  AddOutputFilterByType DEFLATE text/javascript application/json text/html

  RewriteEngine on
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
</Directory>
Run Code Online (Sandbox Code Playgroud)

当我向服务器发出请求时,请求标头包括Accept-Encoding: gzip, deflate,但响应未经压缩返回.每次.conf更改后我都重启了Apache.

任何建议都非常欢迎!

php apache mod-deflate deflate httpd.conf

7
推荐指数
1
解决办法
9322
查看次数

GZIP或DEFLATE可以增加文件大小的最大值是多少?

众所周知,GZIP或DEFLATE(或任何压缩机制)有时会增加文件大小.是否可以增加文件的最大值(百分比或常量)?它是什么?

如果一个文件是X字节,并且我要gzip它,我需要提前预算文件空间 - 最糟糕的情况是什么?

更新:有两个开销:GZIP添加一个标头,通常是18个字节,但基本上是任意长的.DEFLATE怎么样?这可以通过乘法因子扩展内容,我不知道.有谁知道它是什么?

compression gzip deflate information-theory libz

7
推荐指数
1
解决办法
2594
查看次数

启用mod_deflate以发送Content-Encoding:gzip

编辑我发现问题实际上是php缩小.这是发送泄露的内容而不是Apache.我会在此发现更多.

根据高性能网站,如果我在Apache 2.x中启用mod_deflate,通过添加以下行,它应该发送gzipped/delfated内容: -

AddOutputFilterByType DEFLATE text/html text/css application/x-javascript
Run Code Online (Sandbox Code Playgroud)

该书还说,这gzip比更有效deflate.

我通过添加相同的行在httpd.conf中启用.但Apache发送Content-Encoding: deflate.

我使用CURL测试: -

curl -i -H "Accept-Encoding: gzip" "http://192.168.1.33/s.js" >> e:\curl_log.txt
Run Code Online (Sandbox Code Playgroud)

它返回'gzipped'内容.但是当我发送命令时: -

curl -i -H "Accept-Encoding: gzip, deflate" "http://192.168.1.33/s.js" >> e:\curl_log.txt
Run Code Online (Sandbox Code Playgroud)

它返回'放气'的内容.

因此,如果浏览器同时支持deflated和gzip,则Apache发送缩减.如何告诉Apache更喜欢gzip而不是deflate?

仅供参考: -

apache mod-deflate deflate

6
推荐指数
1
解决办法
1万
查看次数

JavaScript膨胀实现(可能只有FF 3.6)

我正在编写一些在FireFox 3.6中使用HTML 5文件API的脚本.我得到了一些放气(压缩)的文件,我需要给它们充气(解压缩).

我在google搜索时发现了一些 脚本,但没有一个有测试.所以我有点不愿意使用它们.

我的问题是:浏览器可以膨胀.我可以通过伪造XHR请求以某种方式捎带通胀吗?或者以任何其他方式搭载?请记住,该脚本目前是FireFox 3.6独有的.但它不能是扩展,我希望它是一个常规网页.

或者,你知道哪些脚本有为它编写的测试?

javascript compression firefox deflate

6
推荐指数
1
解决办法
4496
查看次数

是否在Python上使用zlib.compress,在Java(Android)上兼容Deflater.deflate?

我正在将一个Python应用程序移植到Android,并且在某些时候,该应用程序必须与Web服务进行通信,并向其发送压缩数据.

为此,它使用下一个方法:

def stuff(self, data):
    "Convert into UTF-8 and compress."
    return zlib.compress(simplejson.dumps(data))
Run Code Online (Sandbox Code Playgroud)

我正在使用下一个方法尝试在Android中模拟此行为:

private String compressString(String stringToCompress)
{
    Log.i(TAG, "Compressing String " + stringToCompress);
    byte[] input = stringToCompress.getBytes(); 
    // Create the compressor with highest level of compression 
    Deflater compressor = new Deflater(); 
    //compressor.setLevel(Deflater.BEST_COMPRESSION); 
    // Give the compressor the data to compress 
    compressor.setInput(input); 
    compressor.finish(); 
    // Create an expandable byte array to hold the compressed data. 
    // You cannot use an array that's the same size as the orginal because 
    // there …
Run Code Online (Sandbox Code Playgroud)

python java android zlib deflate

6
推荐指数
2
解决办法
3233
查看次数

与Page Speed产生的相比,Rails Paperclip图像压缩

我已经在rails中设置了回形针,一切都工作正常(我实际上不得不谷歌... :).

我注意到,Page Speed告诉我,我可以进一步压缩缩略图和大图像(回形针产生的图像).我可以在我的模型中添加一个选项吗?我注意到mod_deflate不会压缩图像(我正在使用Firefox).

compression ruby-on-rails deflate paperclip

6
推荐指数
1
解决办法
3774
查看次数

mod deflate不压缩root的子目录

我大约48小时试图解决gzip deflate问题并意识到我可能需要寻求帮助,呵呵呵.

在我意识到我需要在我的php.ini文件中打开压缩后,我终于通过.htaccess在我的共享Unix服务器上启用了deflate模块.

PageSpeed告诉我,我的根HTML是用网站的gzip编码的,我在Wordpress网站上得到了77.3%的压缩theoleandersofsanleon.com但是没有压缩任何子目录中的文件(主要是我的wordpress中的css和js文件)目录及其子目录).

我认为没有必要,但我继续尝试使用指令目录,然后指令位置无济于事.

如果您需要查看任何服务器规格,我会在根目录中放置一个phpinfo.php文件.

以下是我的.htaccess文件中我的htdocs目录和wordpress目录的内容:

<IfModule mod_deflate.c>
# Insert filters
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
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# BEGIN WordPress …
Run Code Online (Sandbox Code Playgroud)

wordpress .htaccess gzip deflate

6
推荐指数
1
解决办法
1609
查看次数

压缩zip存档

我正在尝试使用java将目录内容压缩为zip存档.一切都很好,但我只想澄清一些事实.这是我用来压缩文件的代码:

public void pack(@Nonnull String archiveName, @Nonnull File outputDir, @Nonnull File targetDir) {
  File zipFile = new File(outputDir, "out.zip");

  ZipOutputStream zipOutputStream = null;
  OutputStream outputStream;
  try {
    // create stream for writing zip archive
    outputStream = new FileOutputStream(zipFile);
    zipOutputStream = new ZipOutputStream(outputStream);
    // write files recursively
    writeFiles(zipOutputStream, targetDir.listFiles(), "");
  } catch (IOException e) {
    LOGGER.error("IO exception while packing files to archive", e);
  } finally {
    // close output streams
    if (zipOutputStream != null) {
      try {
        zipOutputStream.close();
      } catch (IOException …
Run Code Online (Sandbox Code Playgroud)

java zip deflate

6
推荐指数
1
解决办法
4669
查看次数

Java解压缩用zlib deflate压缩的字符串

正如标题所说.如何解压缩用zlib压缩压缩的压缩字符串?用解释做这件事的可靠方法是什么?

java zlib deflate

6
推荐指数
1
解决办法
1万
查看次数

在 Angular 2+ 中压缩传出请求

我想对从 Angular 4 应用程序向 API 项目发出的 POST 和 PUT JSON 请求使用 gzip 或 deflate 压缩。

目前,我正在使用 HttpClient 发送请求。我曾尝试使用 pako 或 zlib 来生成压缩内容,但服务器返回响应指示压缩算法的错误实现。

我的 POST TypeScript 如下所示:

public post(url: string, content: any): Observable < any > {
  const fullUrl: string = `${HttpService.baseUrl}/${url}`;

  Logger.debug(`Beginning HttpPost invoke to ${fullUrl}`, content);

  // Optionally, deflate the input
  const toSend: any = HttpService.compressInputIfNeeded(content);

  return Observable.create((obs: Observer < any > ) => {
    this.client.post(fullUrl, toSend, HttpService.getClientOptions()).subscribe(
      (r: any) => {
        Logger.debug(`HttpPost operation to ${fullUrl} completed`, r);

        // …
Run Code Online (Sandbox Code Playgroud)

compression gzip deflate typescript angular

6
推荐指数
1
解决办法
6500
查看次数