• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Speed up WordPress by Gzip Compression from .Htaccess and php flush

By Abhishek Ghosh March 22, 2011 5:16 am Updated on March 22, 2011

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

Advertisement

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.

Google 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:

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|xml|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 GZIP
# DEFLATE compression
<IfModule mod_deflate.c>
# Set compression for: html,txt,xml,js,css
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# Set header information for proxies
Header append Vary User-Agent
</IfModule>
# END DEFLATE
<FilesMatch ".js$">
AddHandler application/x-httpd-php .js
php_value default_mimetype "text/javascript"
</FilesMatch>
<FilesMatch ".css$">
AddHandler application/x-httpd-php .css
php_value default_mimetype "text/css"
</FilesMatch>
<FilesMatch ".(htm|html|shtml)$">
AddHandler application/x-httpd-php .html
php_value default_mimetype "text/html"
</FilesMatch>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
<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=300, private, must-revalidate"
</filesMatch>
</ifModule>

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:

Vim
1
//<?php flush(); ?>

Remove the commenting ( // before < ) to get working php. 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

Tagged With speed up wordpress site htaccess , speed up wordpress using htaccess , php gzip compression install ext/zlib

This Article Has Been Shared 215 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

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

  • Best features of WordPress

    This article Best features of Wordpress describes the features which has established Wordpress in the top position in search engine war.

  • Create a favicon for your WordPress blog

    Branding is a very important factor on the web to differentiate yourself from others, in this article, learn how you can create and add a favicon for your own blog.

  • Configure the robots.txt in WordPress properly for easy crawling

    We will discuss about the optimum settings of this robots.txt file for your Wordpress website.

  • Buying a Ready Made Website : Must Know Points Before Such Deal

    Buying a Ready Made Website is nearly always risky and can end up making your hands dirty.If you have plan to buy an existing website, this guide will be handy.

  • Responsive Web Design, Grid System and Mobile Website

    Responsive Web Design, Grid System and Mobile Website are used for making a website easily viewable on any mobile devices including Tablets. Here is a guide.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Comments

  1. AvatarBill says

    January 30, 2014 at 4:34 am

    This article was written about 10 months ago, do the techniques described still work? Thanks.

  2. Abhishek GhoshAbhishek Ghosh says

    January 30, 2014 at 4:50 am

    Yes, these are basics and will work forever for Apache web server.

  3. AvatarBill says

    January 30, 2014 at 5:02 am

    Thank you for your quick reply, how about on a light speed server?

  4. Abhishek GhoshAbhishek Ghosh says

    January 30, 2014 at 5:21 am

    Since LiteSpeed claims to have compatibility with Apache, it should work. LiteSpeed will follow `mod_rewrite` rules the same way as Apache2.

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Inertial Navigation System? January 25, 2021
  • What is Miniaturization? January 24, 2021
  • What is Domain-Driven Design (DDD)? January 23, 2021
  • Top 10 Anti Hacking Software for Microsoft Windows January 22, 2021
  • What is Software Modernization? January 21, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Speed up WordPress by Gzip Compression from .Htaccess and php flush," in The Customize Windows, March 22, 2011, January 25, 2021, https://thecustomizewindows.com/2011/03/speed-up-wordpress-by-gzip-compression-from-htaccess-and-php-flush/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy