Today, I will talking about ways to improve your website speed or loading time using the .htaccess file. The. htaccess file is a very important file that every webmaster needs to understand. This file is commonly used to control access to sever directories, such as block certain files from users. Additionally, you can also block certain ip addresses and even protect your site from hotlinking! The are several advantages to why your site need to load at an optimum speed. The average time to read a page usually takes about a minute, so visitors don’t have the patients to sit and wait for your sludgy page to load. Below are some useful codes you can add to your .htaccess file to help speed up your website.
The first trick I would like to show is how to speed up you site loading time via file catching. Here is the code you need to add in your .htaccess file in order to catch files on your website:
Header set Cache-Control
Above you can see the file types I have specify to be catched. However, you can add any file type you want.
The next example below shows you how to compress a HTML file:
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/rss+xml
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_exclude mime ^image\.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
Thanks for reading! Check back soon for more .htaccess tricks and useful tips.