Skip to main content
Articles

A Few .htaccess Hacks To Speed Up WordPress

210
0

A couple hacks to speed up WordPress

Open your .htaccess file on your server for editing. Look for the line that says #END WordPress.
All code from this article should go below that line.

Set up GZIP

By enabling this, your server can send out smaller, compressed versions of many files, which browsers know how to decompress. This speeds up the data transfer rate.


# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Add expires headers

Expires headers tell a browser whether a resource can be fetched from the browser’s cache or if it must be retrieved from the server. When you set expires headers for certain resources, such as images or CSS files, the browser knows to store those things in its cache.



# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

# My favicon
ExpiresByType image/x-icon "access plus 1 year"

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access plus 1 month"

# Javascript
ExpiresByType application/javascript "access plus 1 year"

Configure ETags

The ETag, or entity tag, is related to the caching of objects. It’s one of the most commonly reported speed fixes needed for websites.

While ETags do have some advantages, such as better caching and lower bandwidth usage, they can also cause slower load speed and result in the same object ending up cached multiple times. So a preferred route for getting rid of this problem on a WordPress site is to simply turn them off.


#Disable Etags

Header unset Etag
Header set Connection keep-alive

FileETag None

Find the original article here

Corner Icon Render
Corner Icon Render
Corner Icon Render
Corner Icon Render How Can I Help You?