.htaccess - gzip compression code in htaccess not working -
i want compress webpage contents using gzip compression , purpose, using following code in .htaccess file, not working
# begin compress text files <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> # end compress text files
i using this tool test gzip compression, tool tell there no gzip compression in webpage.
is there thing wrong code ? or problem somewhere else.
# 480 weeks ####################################### ### apache configuration directives ### ### mod_gzip 1.3.26.1a ### ####################################### ########################## ### loading module ### ########################## # --------------------------------------------------------------------- # load dll / win32: # loadmodule gzip_module modules/apachemodulegzip.dll # # load dso / unix: # loadmodule gzip_module modules/mod_gzip.so # # (none of both if module has been compiled in statically; # exact file name may depend upon exact compilation method used # module) # --------------------------------------------------------------------- <ifmodule mod_gzip.c> ######################## ### responsibilities ### ######################## # --------------------------------------------------------------------- # use mod_gzip @ all? mod_gzip_on yes # (you can enable mod_gzip inside central server # configuration disable inside directories ot virtual # hosts using directive.) # --------------------------------------------------------------------- ###################################### ### statically precompressed files ### ###################################### # --------------------------------------------------------------------- # let mod_gzip perform 'partial content negotiation'? mod_gzip_can_negotiate yes # (if option active , static file served in com- # pressed for, mod_gzip static precompressed # version of file defined additional extension - see next # directive - delivered priority. allow # avoiding repeatedly compress same static file , # saving cpu time. # no dynamic caching of file provided; user # himself responsible creating , updating precompressed # file's content. # version 1.3.19.2a mod_gzip automatically recognizes whether # statically precompressed file older uncompressed # original , in case serve content of original # file in uncompressed form - rather serve correct data # outdated ones ...) # --------------------------------------------------------------------- # extension (suffix) statically precompressed files mod_gzip_static_suffix .gz addencoding gzip .gz # (effect: see previous directive; string appended # name of original file. # sure configure encoding 'gzip' extension well, # because mod_gzip doesn't serve content generates # apache internal redirection url. therefore remaining # apache configuration responsible setting 'content-encoding' # header ... # prior version 1.3.19.2a value not configurable.) # --------------------------------------------------------------------- # automatic updates statically precompressed files mod_gzip_update_static no # (if set 'yes', directive (being new in version 1.3.26.1a) # cause mod_gzip automatically update outdated version of # statically precompressed file during request, i. e. compress # requested file , overwrite precompressed variant # file it! # each automatic update of type, mod_gzip write message # of severity 'notice' apache error_log. # while doing so, mod_gzip directly read original file's content. # therefore content cannot interpreted other apache module # during request. might possibly not want - # users want, because works fast way. # use configuration lot of care, , sure don't # inadvertantly cause valuable files within url tree overwritten. # isn't feature used mass hosting servers, # because mod_gzip might experience access control problems there - # userid apache processes running under need have write access # precompressed files of users, may not automatically # case.) # [mod_gzip error handling in situation??? served?] # --------------------------------------------------------------------- ################### ### bureaucracy ### ################### # --------------------------------------------------------------------- # display status mod_gzip mod_gzip_command_version '/mod_gzip_status' # (defines url display status of mod_gzip; can specified # individually each installation , protected against access via # <location> section privacy reasons) # --------------------------------------------------------------------- # status display this: # mod_gzip available... # mod_gzip_version = 1.3.26.1a # mod_gzip_on = yes/no # , provide information # - mod_gzip being installed @ server , working correctly, # - version has been installed , # - whether mod_gzip has been set 'active' location # (-> mod_gzip_on) # --------------------------------------------------------------------- ####################### ### data management ### ####################### # --------------------------------------------------------------------- # working directory temporary files , compression cache # if not specified, following default values used: # [win32=c:temp], [unix=/tmp] # mod_gzip_temp_dir /tmp # (this directory must exist , userid being used # running apache server must have read , write access # directory. # unlike other apache directives absolute path name must specified # here; relative value not interpreted relatively serverroot. # pastname must not terminated '/'. # maximum performance directory should located on ram disk, # if file system isn't being cached efficiently # --------------------------------------------------------------------- # save temporary work files [yes, no] mod_gzip_keep_workfiles no # (one file per http request - set 'yes' debugging purpose only!) # --------------------------------------------------------------------- ################## ### file sizes ### ################## # --------------------------------------------------------------------- # minimum size (in bytes) files compressed mod_gzip_minimum_file_size 500 # (for small files compression produce small absolute gains # [you still save 50% of content, additional # 500 bytes of http , tcp headers remain uncompressed], # still produce cpu load both client , server. # mod_gzip automatically set smaller values 300 bytes # directive value 300.) # --------------------------------------------------------------------- # maximum size (in bytes) files compressed mod_gzip_maximum_file_size 500000 # (for large files compression may take rather long , # delay start of transmission. # furthermode limitation @ point prevents server # producing output of unlimited size in case of endless loop # inside cgi script - or trying compress streaming data - # might otherwise cause creation of temporary file of # size , fill whole hard disk. # on other hand, compression have more perceivable # subjective effect large files ... sure fine-tune # according requirements.) # --------------------------------------------------------------------- # maximum size (in bytes) files compressed in memory mod_gzip_maximum_inmem_size 60000 # (larger files compressed temp file directory; adapt # value server's available main memory. # in mod_gzip 1.3.19.x larger values automatically limited # 60000 because operating systems said have problems # allocating more 64 kb of memory @ time. # --------------------------------------------------------------------- #################### ### requirements ### #################### # (see chapter caching problems when using these directives.) # --------------------------------------------------------------------- # required http version of client # possible values: 1000 = http/1.0, 1001 = http/1.1, ... # directive uses same numeric protocol values apache # internally mod_gzip_min_http 1000 # (by using directive may exclude old browsers, search engines # etc. compression procedure: if user agent doesn't # declare capable of understanding @ least http level # specified here, uncompressed data delivered - no matter # else claims able to. value of '1001' # exclude netscape 4.x. , lot of proxy servers.) # --------------------------------------------------------------------- # http methods handled # possible values: 'get', 'post' or list of both values. mod_gzip_handle_methods post # (by using directive may particularly exclude post requests # compression procedure. there known cases # handling of these requests previous mod_gzip versions cause # problems. # before version 1.3.19.2a value not configurable.) # --------------------------------------------------------------------- ############### ### filters ### ############### # --------------------------------------------------------------------- # files compressed? # # order of processing during each of both phases not important, # trigger compression of request's content request # a) must match @ least 1 include rule in each of both phases , # b) must not match exclude rule in of both phases. # these rules not minimal, meant serve example only. # # note parameter values of directives in section # evaluated regular expressions, , not in case-sensitive way. # --------------------------------------------------------------------- # phase 1: (reqheader, uri, file, handler) # ======================================== # no: special broken browsers request gzipped content # aren't able handle correctly mod_gzip_item_exclude reqheader "user-agent: mozilla/4.0[678]" # version 1.3.19.2a on advise against using filters # user-agents, cause http-headers 'vary: user-agent' # generated, making life more difficult proxy servers. # # ja: html-dokumente mod_gzip_item_include file .html$ # # no: include files / javascript & css (due netscape4 bugs) mod_gzip_item_exclude file .js$ mod_gzip_item_exclude file .css$ # # yes: cgi scripts mod_gzip_item_include file .pl$ mod_gzip_item_include handler ^cgi-script$ # # phase 2: (mime, rspheader) # =========================== # yes: normal html files, normal text files, apache directory listings mod_gzip_item_include mime ^text/html$ mod_gzip_item_include mime ^text/plain$ mod_gzip_item_include mime ^httpd/unix-directory$ # # no: images (gif etc., ever save anything) mod_gzip_item_exclude mime ^image/ # --------------------------------------------------------------------- # in fact mod_gzip checking first 4 characters of 1st # operand (in case of uri first 2 characters only, # allow values url). # --------------------------------------------------------------------- # table mod_gzip_item rules (include , exclude) cannot contain # more 256 entries; when number exceeded mod_gzip # output message "mod_gzip: error: item index full" # , report configuration error apache server. # --------------------------------------------------------------------- # directive values described here meant describe requests # elected compression exactly. # mime rules has made clear http # header 'content-type' (that checked mod_gzip rule) # in cases may contain not mime type additionally # character set description (charset) well. # if case requests handled need # remove '$' char @ end of corresponding value # prefix of value tested matching. # --------------------------------------------------------------------- ########################## ### transfer encodings ### ########################## # --------------------------------------------------------------------- # allow mod_gzip eliminate http header # 'transfer-encoding: chunked' # , join chunks 1 (compressable) packet mod_gzip_dechunk yes # (this required handling several types of dynamically generated # contents, cgi , ssi pages, pages produced # java servlet interpreters. # --------------------------------------------------------------------- ############### ### logging ### ############### # --------------------------------------------------------------------- # extended log format (for testing compression effect) logformat "%h %l %u %t "%v %r" %<s %b mod_gzip: %{mod_gzip_result}n in:%{mod_gzip_input_size}n -< out:%{mod_gzip_output_size}n = %{mod_gzip_compression_ratio}n pct." common_with_mod_gzip_info2 # --------------------------------------------------------------------- # create additional log file customlog logs/mod_gzip.log common_with_mod_gzip_info2 # (surely can redefine normal log file format, mal # keep format standard compatible evaluation standard web # analysis tools. create log file.) # --------------------------------------------------------------------- # volume computation of delivered files inside apache access_log: # count http header size (in bytes) part of total output size mod_gzip_add_header_count yes # (this more pure document content, more # realistically describe total output traffic of http request) # --------------------------------------------------------------------- ############### ### proxies ### ############### # --------------------------------------------------------------------- # sending 'vary' http header mod_gzip_send_vary on # (see chapter caching directive.) # don't change unless absolutely know doing! # --------------------------------------------------------------------- </ifmodule>
try :)
Comments
Post a Comment