GZip Optimisation chargement de page

Un petit truc assez sympa à mettre en place surtout avec les CMS comme Wordpress ou Joomla, qui se révèle assez gourmand si comme moi vous l'héberger sur un Nas. Les pages sont longues à charger coté clients et si par mal chance vos pages sont chargées en code ou en image trop volumineuses, c'est horrible!

Faire un check de votre machine et contrôler que le paquet GZip est bien installé:

  Pour les Machines Linux: dpkg -l gzip

Pour installer le paquet en question.

  Pour les Machines Linux: apt-get install gzip
  Pour les Nas Synology ou Qnap: ipkg install gzip

La solution consiste à modifier votre fichier .htaccess à la racine de votre sites Web ou tout simplement dans créer un et d'y coller le code si dessous:

  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
  AddType text/css .css
  AddType application/x-javascript .js
  AddType text/x-component .htc
  AddType text/html .html .htm
  AddType text/richtext .rtf .rtx
  AddType image/svg+xml .svg .svgz
  AddType text/plain .txt
  AddType text/xsd .xsd
  AddType text/xsl .xsl
  AddType text/xml .xml
  AddType video/asf .asf .asx .wax .wmv .wmx
  AddType video/avi .avi
  AddType image/bmp .bmp
  AddType application/java .class
  AddType video/divx .divx
  AddType application/msword .doc .docx
  AddType application/vnd.ms-fontobject .eot
  AddType application/x-msdownload .exe
  AddType image/gif .gif
  AddType application/x-gzip .gz .gzip
  AddType image/x-icon .ico
  AddType image/jpeg .jpg .jpeg .jpe
  AddType application/vnd.ms-access .mdb
  AddType audio/midi .mid .midi
  AddType video/quicktime .mov .qt
  AddType audio/mpeg .mp3 .m4a
  AddType video/mp4 .mp4 .m4v
  AddType video/mpeg .mpeg .mpg .mpe
  AddType application/vnd.ms-project .mpp
  AddType application/x-font-otf .otf
  AddType application/vnd.oasis.opendocument.database .odb
  AddType application/vnd.oasis.opendocument.chart .odc
  AddType application/vnd.oasis.opendocument.formula .odf
  AddType application/vnd.oasis.opendocument.graphics .odg
  AddType application/vnd.oasis.opendocument.presentation .odp
  AddType application/vnd.oasis.opendocument.spreadsheet .ods
  AddType application/vnd.oasis.opendocument.text .odt
  AddType audio/ogg .ogg
  AddType application/pdf .pdf
  AddType image/png .png
  AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
  AddType audio/x-realaudio .ra .ram
  AddType application/x-shockwave-flash .swf
  AddType application/x-tar .tar
  AddType image/tiff .tif .tiff
  AddType application/x-font-ttf .ttf .ttc
  AddType audio/wav .wav
  AddType audio/wma .wma
  AddType application/vnd.ms-write .wri
  AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
  AddType application/zip .zip

Vous pouvez filtrer les entrées ci dessus et enlever les extension que votre site ne gère pas. Le code sera plus clair à relire.

Penser à activer GZip dans Php.ini de votre conf Apache!