in

Optimizing Tricks Speedup WordPress, PHP or Any Site Using Htaccess

Optimizing Tricks Speedup WordPress, PHP or Any Site Using Htaccess

Speedup WordPress, PHP or Any Site Using Htaccess: From normal website bloger to advanced level website developer, evenrone has a thought in mind – that is how to get more and more traffic. To achive that many parameters are their but website speed is one of them. This fact made us fascinated about the way to increase web page speed, we can easily do that by the use of Htaccess of WordPress, php or any other type of website. There are a number of tactics to Increase WordPress speed with the use of .htaccess file but what about other sites? they also can use the same. In this article, I will walk you thru five Htaccess hacks to speed up php, WordPress or any other web page just within a minute.

According to a internet survey, websites ta loads within 2 sec are expected to get higher in search engine’s ranking.  

 How To Increase your website’s Page Speed Using Htaccess WordPress, PHP etc.

  It is very vital to optimize your beloved website speed to give visitors a smooth surfing experience. Search engines like google, bing, yahoo also like faster web page loading speed. If you already know the Htaccess hacks to optimize or speed up WordPress site, php or any other sites, then also this article can help you to brush up that or whether you have missed something in your optimization tricks ir not. For beginners, I would highly recommend you to read whole article and apply those accordingly. Let’s start……

How to Increase Page Speed using Htaccess

  1. Start webpage Compression –Level is Gzip and DEFLET
  2. Enable the Keep Alive on your server
  3. Leverage Browser Caching
  4. Disable the Image Hotlinking
  5. Activate the mod_pagespeed
  6. Enable the LightSpeed Server Cache, if you are using lightspeed server.

Enable Gzip Compression to Speed up WordPress, php or any website using Htaccess:

For Apache Server: –

Increase Page Speed using Htaccess

Just copy and paste the following code to .htaccess file:

<IfModule mod_deflate.c>
  # 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
</IfModule>

For NGINX 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;

Enable Gzip Compression to Speed up WordPress, php or any website using Htaccess:

# FatSage 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

Enable The Keep Alive Option For Apache Server

To Increase Page Speed using Htaccess: Keep Alive enebling is an another very powerful hack. It makes the communication between your server and web browser very smooth and facilitate downloading resources on just a single connection. This feture is automatically enabaled in nowadays modern servers. But if it is not then you can use the following code to enable it. Add the following code to your .htaccess file:

# FatSage START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# FatSage END ENABLE KEEP ALIVE

Disable Image Hotlink To speed Up your website:
Add the following code to your .htaccess:

# FatSage – DISABLE IMAGE HOTLINKIING START
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sample.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
# FatSage – DISABLE IMAGE HOTLINKIING END

Enable Mod_pagespeed to increase the speed of your php, wordpress or any website:

Add the following code into .htaccess file:

# FatSage – 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>
# FatSage – ENABLE MOD PAGESPEED END

Enable LightSpeed Server Cache:

If your server is LightSpeed Server then only use the following code:

# FatSage – 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>
# FatSage – ENABLE LITESPEED CACHE END

Setting Up the Expire HTTP Headers:

To Increase Page Speed using HtaccessExpire headers Setting is another powerful hack you can apply and it is very simple. Just insert the following code to your .htaccess file:

# Set Expires Headers
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Jan 2015 20:00:00 GMT"
</FilesMatch>

Setup The Cache-Control Headers to increase the speed of your website:

To Increase Page Speed using Htaccess: This cache-control headers feature gives you the power to take your wordpress, php or any website speed to the next level. Just copy and paste the following code to your .htaccess file to enable the feature:

# Set the cache-control max-age
# 1 year
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=31449600, public"
</FilesMatch>
# 2 DAYS
<FilesMatch ".(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>
# 4 HOURS
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=14400, must-revalidate"
</FilesMatch>

Remove ETags and Last Modified through .htaccess:

Speedup WordPress or Any Site Using Htaccess:

Just copy and paste the following code to .htaccess file. after that check your website once whether there is any problem in loading the site or not. If you fond any problem just remove the code. Successful working of this code depends on the type of apache server you are using.

# Turn off the ETags
Header unset ETag
FileETag None

# Turn off the Last Modified header except for html docs
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
</FilesMatch>

Written by FatSage Sankar

SEO Analyst, Web Designer, Web Developer, App Developer. Works on Wordpress, Magento, Drupal. PHP, CSS, HTML etc.

Comments

Leave a Reply

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

Loading…

1000 Of Free Guest Blogging Quality Websites For Seo

32 Best Free And Paid Seo Plugin/ Tools For WordPress