GZIP, Apache, PHP: What should I know for implementation on a mature site?

Apache 2.2.17 PHP 5.3.3

Currently my application does not use gzip, but I would like to. However, I am not sure about some things:

  • I know that IE6 has problems with this; no need to come back here.
  • What are the advantages / disadvantages for implementing this in Apache (mod_deflate) and PHP? Do they get basically the same result? I believe that Apache would be more efficient, is this the correct assumption?
  • The application generates quite a few types of answers: pdf, xml, zip, xls, csv, images (see the next paragraph) and, of course, ordinary material like AJAX.
  • I saw that many examples prefer not gzip images, but why? Is this due to the assumption that most of the images are already in a compressed format, or is it due to the fact that this is binary data? I dynamically create some images and the old old role of others.
  • I also transfer audio files (wav, mp3) using the PHP engine; Anyone got here?

In fact, if you implemented gzip on a mature site and ran into problems, I would like to know what it is and what you did to solve these problems. Thank!

+3
source share
2 answers
  • Nothing else can be said

  • Apache, . css js, .

  • Apache

  • . , bmps, , , , gzip, gif, png, jpg .

  • , , . , , , , .

, gzip , Apache . , , .

+5

bmp ( , - , ), , jpeg, png gif.

, - ( Google):

# Insert filter
<FilesMatch "(?i)^.*\.(js|css|html?|php3?|xml|txt)$">
    SetOutputFilter DEFLATE
</FilesMatch>
# *.cache.js and *.cache.css files are only checked after 6 month (e.g. jQuery.1.4.2.cache.js)
<FilesMatch "(?i)^.*\.(cache)\.(js|css)$">
    FileETag None
    ExpiresActive On
    ExpiresDefault "access plus 6 month"
</FilesMatch>
#AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

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

, , , *.cache.js *.cache.css 6 , . . jqueryui.cache.css

+1

Source: https://habr.com/ru/post/1772715/


All Articles