Codementor Events

Web site Speed optimization

Published Jul 18, 2017
Web site Speed optimization

What is the page speed ?

A website contents Web pages or media content is downloaded from website hosting servers and displayed onto the requesting Web browser.

You can check your webpage speed from following third party:

  1. https://developers.google.com/speed/pagespeed/insights/
  2. https://tools.pingdom.com/
  3. https://gtmetrix.com/

Those all above provide your webpage speed as well details report to imporve your speed.

Why page speed is important ?

Website performance subsequently impacts search engine rankings. and also for good user experience.website speed is really matter for your online business.

How to improve that?

**1) Enabled gzip and cache **
mod_gzip is an external extension module for Apache that allows you to quickly and easily compress your files before you send them to the client.

Open your .htaccess file on root directory

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

Add cache control header

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

Adding expires headers do not affect the site load time for a first time visitor but you will be surprised how much the page load time decreases (faster page load) for subsequent page views/return visits from that visitor.

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</IfModule>

2) Minify js and css

It is always best practice to minify css and js before load. Also you should combine of all css and js files as possible so we can reduce server request.

3) Enable keep-alive using .htaccess

<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>

4) Optimise Images
This is one that is also commonly overlooked. If your website has lots of images or large images then they will take time to load.

There are lot's of third party provider to optimise images

  1. https://tinyjpg.com/
  2. http://optimizilla.com/
  3. Google guetzli
    That is much better than all other.details instruction is here (https://github.com/google/guetzli)

There are also many points you should consider for page speed:

  1. Minimize redirects
  2. Avoid bad requests
  3. Use CDN
  4. Remove query strings from static resources
Discover and read more posts from Mayur Kalathiya
get started
post commentsBe the first to share your opinion
Show more replies