Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

nginx gzip config

  # output compression saves bandwidth 
  gzip              on;
  gzip_proxied      any;
  gzip_http_version 1.1;
  #gzip_min_length   1100;
  gzip_comp_level   5;
  #gzip_buffers      4 8k;
  gzip_types        text/plain text/html text/xml text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/atom+xml;
  #gzip_vary        on;
  #gzip_disable     "MSIE [1-6]\.";

unix, pack folder and contents with tar gz

tar -zcvf packagename.tar.gz folder/

Enabling Zip compression with PHP

// if you want to reduce the bandwidth bill and increase page load time for long pages - this PHP snippet will turn on gzip compression for those that support it.

function compress_handler($in_output)
{
  return gzencode($in_output);
}
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== FALSE)
{
  ob_start('compress_handler');
  header('Content-Encoding: gzip');
}
else
{
  ob_start();
}

Using gzip module

Modified from this funny thread in c.l.p
http://groups.google.co.uk/group/comp.lang.python/msg/e53361331c23fd76

import gzip

zfile = gzip.GzipFile('somefile.gz')
content = zfile.read()
zfile.close()
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS