Speedup page load time with apache on ubuntu.

Speedup page load time with apache on ubuntu.

vijay / July 15, 2017

Some of the key role in order to increase your page load time are :

  1. leverage browser caching

This is the step how you can do this stuff.

a2enmod headers
a2enmod expires

vim /etc/apache2/conf-available/lbcache.conf

put this content

<IfModule mod_expires.c>
# Turn on the module.
ExpiresActive on
# Set the default expiry times.
ExpiresDefault "access plus 2 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 600 seconds"

Save the file .

a2enconf lbcache

service apache2 restart


2) use memcache to cache dynamic content

using a local caching is best option to cache dynamic pages so that they can be served easily without involving your webserver for request and hence this speedup your request.

apt-get install php5-memcached memcached

service memcached restart

3) Using apache handler to serve php content is never can be a good option for a good traffic websites. Hence we recommend to use fpm handler instead.

apt-get install libapache2-mod-fastcgi php5-fpm  apache2-mpm-event

vim /etc/apache2/conf-available/php5-fpm.conf

a2enconf php5-fpm actions fastcgi alias

service apache2 restart && service php5-fpm restart

if you got an error in your vps that libapache2-mod-fastcgi package is not found then do following

vim /etc/apt/sources.list

deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

Now run apt-get update and try again

4) Auto minify js when serving from apache.

UglifyJS is a tool in ubuntu which works with apache module mod_ext_filter and minify all js lets enable it

apt-get install uglifyjs

a2enmod ext_filter

vim /etc/apache2/conf-available/jsminify.conf

<IfModule mod_ext_filter.c>
ExtFilterDefine jsminify\
intype=application/javascript outtype=application/javascript\

a2enconf jsminify

service apache2 restart

In your .htaccess file add this line

SetOutputFilter jsminify

5) enable google page speed module

for 64 bit wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

for 32 bit wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb

dpkg -i mod-pagespeed*.deb

service apache2 restart


Advantages of Crazy Tech India NGINX VPS

Build a super fast website on super fast web server, Nginx fast cgi caching,and pagespeed enabled. KVM Virtualized VPS dedicated resource gauranteed, Free monitoring. Starts INR 749/M

@ 2017 Crazy Tech India -Web Hosting company