Bedpage

How to Increase WordPress Website Loading Speed Using Htaccess

Regardless of whether you are a designer or a standard web user, practically we all love quicker websites. This post is focused on how to Increase Page Speed using Htaccess (WordPress). You may definitely realize that there are a lot of approaches to speed up WordPress using Htaccess code. In the following article, I will walk you through five best Htaccess stunts to optimize site speed.

First, of all, we should begin with a list of Htaccess tricks to speed up, which I am going to cover in this post. The list I have arranged spreads the significant proposals by the vast majority of the web developers on the world to speed up WordPress website using Htaccess.

How to improve WordPress site speed via htaccess

  • Enable Gzip Compression
  • Enable Keep Alive
  • Leverage Browsing Caching
  • Activate mod_pagespeed
  • Enable Light Speed Server Cache

Note: Submit your Guest post @ $50 & Add your website to the list at the top at $25. Website traffic 30k+ per month. Email Me 

1. Enable Gzip Compression:-

The first Htaccess trick on the list is Gzip compression

I am able to reduce page size by 73% by enabling Gzip Compression on my website.

* Gzip Compression on Apache

# TN START GZIP COMPRESSION

<IfModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_item_include file \.(html?|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>

# TN END GZIP COMPRESSION

* DEFLATE Compression on Apache

# TN START DEFLATE COMPRESSION

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE “application/atom+xml” \

“application/javascript” \

“application/json” \

“application/ld+json” \

“application/manifest+json” \

“application/rdf+xml” \

“application/rss+xml” \

“application/schema+json” \

“application/vnd.geo+json” \

“application/vnd.ms-fontobject” \

“application/x-font” \

“application/x-font-opentype” \

“application/x-font-otf” \

“application/x-font-truetype” \

“application/x-font-ttf” \

“application/x-javascript” \

“application/x-web-app-manifest+json” \

“application/xhtml+xml” \

“application/xml” \

“font/eot” \

“font/otf” \

“font/ttf” \

“font/opentype” \

“image/bmp” \

“image/svg+xml” \

“image/vnd.microsoft.icon” \

“image/x-icon” \

“text/cache-manifest” \

“text/css” \

“text/html” \

“text/javascript” \

“text/plain” \

“text/vcard” \

“text/vnd.rim.location.xloc” \

“text/vtt” \

“text/x-component” \

“text/x-cross-domain-policy” \

“text/xml”

</IfModule>

# END DEFLATE COMPRESSION

Note: Submit your Guest post @ $50 & Add your website to the list at the top at $25. Website traffic 30k+ per month. Email Me 

* Compression on NGINX server

Paste the following Htaccess code in the configuration file of your web server.

gzip on;

gzip_comp_level 2;

gzip_http_version 1.0;

gzip_proxied any;

gzip_min_length 1100;

gzip_buffers 16 8k;

gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

gzip_disable “MSIE [1-6].(?!.*SV1)”;

gzip_vary on;

2. Enable Keep Alive:

Adding Keep-Alive is another amazing Htaccess stunt to accelerate the WordPress site. It empowers your server and internet browser to download assets on a single connection, henceforth it speeds up. You can add Keep-Alive by including ‘Connection: Keep-Alive’ HTTP header in your server.

Paste the following Htaccess code in the configuration file of your web server.

# TN START ENABLE KEEP ALIVE

<ifModule mod_headers.c>

Header set Connection keep-alive

</ifModule>

# TN END ENABLE KEEP ALIVE

3. Leverage Browser Caching via Htaccess:

Leverage Browser Caching using Htaccess is one of the most prescribed Htaccess tricks to accelerate the WordPress site by the developers.

Paste the following Htaccess code in the configuration file of your web server.

* Add Expires headers to leverage browser caching via Htaccess

# TN – START EXPIRES CACHING #

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType text/css “access 1 month”

ExpiresByType text/html “access 1 month”

ExpiresByType image/gif “access 1 year”

ExpiresByType image/png “access 1 year”

ExpiresByType image/jpg “access 1 year”

ExpiresByType image/jpeg “access 1 year”

ExpiresByType image/x-icon “access 1 year”

ExpiresByType image/svg+xml “access plus 1 month”

ExpiresByType audio/ogg “access plus 1 year”

ExpiresByType video/mp4 “access plus 1 year”

ExpiresByType video/ogg “access plus 1 year”

ExpiresByType video/webm “access plus 1 year”

ExpiresByType application/atom+xml “access plus 1 hour”

ExpiresByType application/rss+xml “access plus 1 hour”

ExpiresByType application/pdf “access 1 month”

ExpiresByType application/javascript “access 1 month”

ExpiresByType text/x-javascript “access 1 month”

ExpiresByType text/x-component “access plus 1 month”

ExpiresByType application/x-shockwave-flash “access 1 month”

ExpiresByType font/opentype “access plus 1 month”

ExpiresByType application/vnd.ms-fontobject “access plus 1 month”

ExpiresByType application/x-font-ttf “access plus 1 month”

ExpiresByType application/font-woff “access plus 1 month”

ExpiresByType application/font-woff2 “access plus 1 month”

ExpiresDefault “access 1 month”

</IfModule>

# TN – END EXPIRES CACHING #

* Add Cache-Control Headers to Increase Page Speed using Htaccess (WordPress)

 

# TN – BEGIN Cache-Control Headers

<ifModule mod_headers.c>

<filesMatch “\.(ico|jpe?g|png|gif|swf)$”>

Header set Cache-Control “public”

</filesMatch>

<filesMatch “\.(css)$”>

Header set Cache-Control “public”

</filesMatch>

<filesMatch “\.(js)$”>

Header set Cache-Control “private”

</filesMatch>

<filesMatch “\.(x?html?|php)$”>

Header set Cache-Control “private, must-revalidate”

</filesMatch>

</ifModule>

# TN – END Cache-Control Headers

Note: Submit your Guest post @ $50 & Add your website to the list at the top at $25. Website traffic 30k+ per month. Email Me 

4. LightSpeed Server Cache:

Notwithstanding that, in the event that you are utilizing LightSpeed Server to run your site like we used to utilize LightSpeed Server with A2Hosting. You should utilize the accompanying Htaccess code to empower server-level reserving. This will speed up your WordPress site altogether.

Paste the following Htaccess code in the configuration file of your web server.

# TN – ENABLE LITESPEED CACHE START

<IfModule LiteSpeed>

CacheEnable public

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^GET|HEAD$

RewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org [NC]

RewriteCond %{REQUEST_URI} !login|admin|register|post|cron

RewriteCond %{QUERY_STRING} !nocache

RewriteRule .* – [E=Cache-Control:max-age=300]

</IfModule>

# TN – ENABLE LITESPEED CACHE END

5. Enable MOD page speed:

Mod_pagespeed module was created by Google to speed up sites. These days, few Hosting Providers like Godaddy, SiteGround and DreamHost and so forth underpins mod_pagespeed module as a matter of course. Be that as it may, you can have installed the equivalent by adding SSH on your control panel.

 Paste the following Htaccess code in the configuration file of your web server. 

# TN – ENABLE MOD PAGESPEED START

# COMBINE CSS, COMPRESS IMAGES, REMOVE HTML WHITE SPACE AND COMMENTS

<IfModule pagespeed_module>

ModPagespeed on

ModPagespeedEnableFilters rewrite_css,combine_css

ModPagespeedEnableFilters recompress_images

ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp

ModPagespeedEnableFilters collapse_whitespace,remove_comments

</IfModule>

# TN – ENABLE MOD PAGESPEED END

Ritvik

Ritvik is a passionate blogger at LinksKorner. He loves to share his knowledge about the latest and productive Link building Resources through his blogs. Apart from writing, he finds reading books on Digital Marketing as interesting. For more info contact us here. For Advertise on LinksKorner, visit Advertise page.

Leave a Reply

Your email address will not be published. Required fields are marked *