Website speed is critical to build a business success. But sometimes, we just have limited budget for our small website. We are unable to purchase expensive speed up service like CDN. When this happens, how to make website download faster?
Choose Nearby web hosting
All website data transferring between web hosting and readers’ client need passing through network cable and transit in network nodes. The longer the distance, the longer the cable and the more nodes. Data transit in cable and nodes has a fixed speed. Choose a web hosting nearby the targeted reader will definitely decrease transmit time. This is the basic theory for CDN. That means, if you are running local business, best idea is the web hosting in your area with comparatively cheap price.
Enable Gzip compression
Gzip compression works in the same way as compressing file on PCs. Once enabled, Gzip automatically compresses website’s files in Gzip format before sending them for download. This method of transmitting content from the server to the browser is far more efficient and saves a lot of time. According to Yahoo, this can reduce download time by about 70%.
Enable the deflate module
Create Gzip configuration
Add the following code to Apache configuration or the .htaccess file (found in the root directory on your server):
Enable keep-alive connection
Keep alive is a method to enable multiple HTTP requests in the same tcp connection. When keep alive not enabled, each HTTP request set a tcp connection. Client browser sent HTTP request for each document which takes significantly longer to display the webpage. The keep alive enables grab more than just one file at a time.
For Apache configuration:
Find KeepAlive and make it
For .htaccess configuration:
<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>
Enable browser caching
Enable expire module
In a LAMP stack, type this snippet:
Browser caching configuration
Add the following lines to Apache configuration or the .htaccess file. It specify the file type to cache and its expire time. The A86400 state the file cache expire after 86400 second.
Use PHP OPcache
OPcache is a build in module in PHP from PHP5.5. It is formerly the Zend Optimizer. It improves PHP performance by storing precompiled script bytecode in the shared memory. Enable OPcache module will speed up your PHP application.
Open the php.ini file and ensure the configuration as follow:
;enable the Zend opcache opcache.enable=1 ;maximum memory opcache can use. (in megabytes) opcache.memory_consumption=256 ;The maximum number of keys (scripts) in the OPcache hash table. opcache.max_accelerated_files=5000 ;How often (in seconds) to check file timestamps for changes to the shared memory storage allocation. opcache.revalidate_fre=240
Use Google Apache module mod_pagespeed
The mod_pagespeed is a open source Apache module from Google. It is aimed to speed up website and save bandwidth. Use the following command to install the mod_pagespeed.
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_amd64.deb sudo dpkg -i mod-pagespeed-*.deb sudo apt-get -f install
The default mod_pagespeed configuration has enabled many safe functions like combine CSS, compressor CSS, etc. For more information, check https://developers.google.com/speed/pagespeed/module/
After these steps, don’t forget to restart Apache server.
service restart apache2
Use Google Pagespeed check you website speed for something more can be improved: https://developers.google.com/speed/pagespeed/insights/
For a shared hosting, the same method can be used. But you may need to contact hosting administrator to make sure you have the authority.