Improving web site performance with Apache .htaccess
Speed optimizations can be easily done with simple .htaccess rules. These rules can make any website faster by compressing content and enabling browser cache.
.htaccess is a special configuration file which you should be able to dig up in the root of your server directory. With a .htaccess file you file you can create redirects, rewrite URLs on your website, create password protected directories and other technical things, but you can also use them to improve your site’s page loading speed by taking advantage of some Apache server features.
Compression reduces response times by reducing the size of the HTTP response. It’s worthwhile to gzip your HTML documents, scripts and stylesheets. Gzip compression helps to reduce the amount of data your server needs to send to your users, which in turn speeds up the load time of your site.
You can use the Apache mod_deflate module to compress output from your web site that is sent to client browsers.
When a new visitor enters your website all the files like scripts, CSS styles and images are downloaded – there is no way to avoid it and it naturally produces several requests to your server. But what if this visitor comes back to your website later? We can tell the user’s browser to store these files in its cache; then, when the user returns to your site it will reload the files from the cache rather than downloading them all again.
In order to add browser caching to your website, you will need to set the date for when the cache expires.
Browser cache control is directly related with to the header expires date and according to the Apache, documentation provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed. You can use this feature by including this code in your htaccess
<IfModule mod_headers.c> Header set Connection keep-alive <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"> Header set Cache-Control "max-age=2678400, public" </filesmatch> <filesmatch "\.(html|htm)$"> Header set Cache-Control "max-age=7200, private, must-revalidate" </filesmatch> <filesmatch "\.(pdf)$"> Header set Cache-Control "max-age=86400, public" </filesmatch> <filesmatch "\.(js)$"> Header set Cache-Control "max-age=2678400, private" </filesmatch> </IfModule>
After installing AbanteCart an a .htaccess file is already created, but it’s called .htaccess.txt and looks like a regular text file. The reason for this? Compatibility. There’s no guarantee that every server that AbanteCart is installed on will support .htaccess features. Don’t worry though; most modern servers that are built to support AbanteCart will also support .htaccess
Enable HTML pages and blocks caching to get better speed for your pages. HTML cache currently is Beta and can be enabled in System > Settings > → Settings → System. This is additional caching to regular data caching enabled in system/config.php file
Test well your site after enable HTML Cache, not all templates or third party extension fully support this feature
Starting AbanteCart 1.2.7 additional drivers available for configuration are APC, APCU, FILE, MEMCACHE, MEMCACHED, XCACHE
Change cache driver in the /system/config.php file
All available drivers located in the /core/cache/ folder
3rd party extensions or cPanel
Review your hosting service plan
Check with your hosting provider to see whether you have shared or dedicated hosting. A shared hosting account often involves sharing server space with dozens of other companies where website speed is impacted by the number of people using the servers. If this is the case, then it may be time to consider a dedicated plan where you have sole access to the server.
PHP 7 came with drastically improved performance and memory usage when compared to PHP 5.6
Changing your php version PHP version to modern 7.0 can improve overall server's performance.