Speed up WordPress by Gzip Compression from .Htaccess and php flush


Before describing the manipulation to be done to accelerate the speed of your site and reduce loading times, we want to clarify that some of these tips work well for sites that are not under WordPress.

said that the speed of page loading was a factor to consider in the SEO, then we should better optimize it.

 

Open to edit your  .Htaccess file (take a backup first). For us, using online FTP works great to do the job. Add the following codes to your  .Htaccess file before the starting of your WordPress rewrite rules:

 


< ifModule mod_gzip.c >
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt||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 ^/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
< /ifModule >

< ifModule mod_expires.c >
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
< /ifModule >

< ifModule mod_headers.c >
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
< /filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
< /ifModule >

< ifModule mod_headers.c >
Header unset ETag
< /ifModule >
FileETag None

 


Update: Unfortunately, the if module syntax is not showing up properly. So, here is the file for you, just click to open it.

In case mess up, just delete the codes and save it or replace with your backup file.

You can read this interesting and useful topic to optimize the pageload speed from Yahoo. It really nicely written. You can implement PHP buffer flush to load very quickly. We used both of this methods to make this website load faster. For implementing PHP buffer flush; add this in your header . php ( just after closing of head tag) file via Theme editor:

 

<?php flush(); ?>

 

This will decrease the waiting time (particularly if the server is long away from the visitor) with a blank screen on browser waiting for full page to load.

 

Signature


Incoming search terms:

wordpress gzip htaccess,gzip wordpress htaccess,wordpress htaccess gzip
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
About Abhishek

Abhishek Ghosh is an Orthopedic Surgeon, Inventor with 216 Patents, Current editor of The Customize Windows Media Group. You can follow and know more about Dr. +Abhishek Ghosh on Google Plus and follow on Twitter as @AbhishekCTRL.

Trackbacks

  1. [...] factor is more page loading time. Try to reduce the time visitors sees the blank white page by flushing the buffer early and leveraging the browser [...]

  2. [...] consider all aspects. If you are not using CDN, then WP Super Cache with WP minify will work great. However, in both cases, a bit .htaccess tweak will be needed. There is another good cache plugin named W3 Total [...]

  3. 10 consejos para optimizar nuestro WordPress | Diseño Web y gráfico | HGR Design says:

    [...] Utiliza un plugin de cache o compresión en el servidor Algo que siempre te agradece el usuario y google es que tu sitio web sea lo más rápido posible y una de las formas de cumplir este objetivo [...]

Speak Your Mind

*