Home

Improve osclass load speed

Introduction

Site speed is one of core elements that makes different between successful and unsuccessful classifieds. By default osclass is not well optimized plus themes nad plugins makes it even harder, however it's worth to spent some time on osclass load speed improvements as google consider site speed in it's rating as well.

 

Hosting

First important element is your hosting. There is no osclass optimized hosting, however you should be able to easily find best for you:

  • not cheapest one, proper osclass hosting should cost approx. $50, depending on region and services
  • PHP7 is must, makes your classifieds loading faster
  • use MySQL 5.7 version for your database
  • good hosting will provide memcache caching system, that levarages sql queries to database
  • choose regional (in-country) hosting, otherwise your users may suffer from slow site loading. Server should be closest to your customers.

Your hosting company should provide also automatic backups of database and file system for at least 1 week.

If your hosting has memcache enabled, add following to your config.php

define('OSC_CACHE', 'memcache');
$_cache_config[] = array('default_host' => '127.0.0.1', 'default_port' => 11211, 'default_weight' => 1);

 

SSL certificate

One of most important osclass speed factors is using of SSL certificate. Even SSL is to secure connection of your users so noone can easily read password and other confidential data when submitting forms, usage of https possitively improve website speed. This increase can be really high, like twice faster load time comparing https:// version to http:// version.

Nowadays Let's Encrypt provides free SSL certificates so it's not a problem to secure whole site including it's subdomains - for free! Your hosting should have this enabled.

Once you setup SSL certificate and your https:// version of site is loading correctly, add following code to .htaccess file to ensure when user enters to http:// version, there is instant redirect to https:// version of osclass.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>

 

.htaccess configuration

Is most known for securing friendly URLs, but provides a lot of options to optimize your site. This file should be placed in installation root and you should work with it carefuly. Do not forget to backup this file before each change. Using .htaccess file you can enable apache optimization, image size reduction and much more your osclass will benefit from. To enable friendly URLs, redirect http:// to https:// and compress images, disable cache control and few other improvements, add following code to your .htaccess

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] <filesMatch ".(css(\?.+)?|jpg|jpeg|png|gif|js(\?.+)?|ico)$"> Header set Cache-Control "max-age=0, public, must-revalidate" RewriteEngine On RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=604800, public" 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.* # BEGIN Expire headers ExpiresActive On ExpiresDefault "access plus 5 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" ExpiresByType text/javascript "access plus 216000 seconds" ExpiresByType application/javascript "access plus 216000 seconds" ExpiresByType application/x-javascript "access plus 216000 seconds" ExpiresByType text/html "access plus 600 seconds" ExpiresByType application/xhtml+xml "access plus 600 seconds" # END Expire headers # BEGIN Cache-Control Headers <filesMatch "\.(ico|jpe?g|png|gif|swf)$"> Header set Cache-Control "public" <filesMatch "\.(css)$"> Header set Cache-Control "public" <filesMatch "\.(js)$"> Header set Cache-Control "private" <filesMatch "\.(x?html?|php)$"> Header set Cache-Control "private, must-revalidate" # END Cache-Control Headersphp_value opcache.enable 0 php_value opcache.enable 0

 

Osclass image dimension

This point is directly related to osclass settings - image size. Go to oc-admin > Settings > Media and properly setup size for thumbnails, preview and normal images. Best rule is to find what is maximum dimension of images shown on your theme, including desktop and mobile version. You should choose proper aspect ratio as well, probably most common is 4:3.

As example, for Stela Osclass Theme preferable image dimension is:

  • thumbnails: 360x240 px
  • preview: 480x360 px
  • normal: 800x600 px

Most important is that your pictures are not too large. You still will get notifications when using google pagespeed that you should reduce image size, but considering mobile devices this is usually not possible.

Once you change image sizes in your osclass, it is required to regenerate thumbnails to make changes effective. More images = more resources needed to regenerate images, therefore it's good practice to increase maximum allowed PHP run time to 600 seconds. If you have thousands of listings, regenerate will not be possible for all of them.

 

Themes and plugins optimization

Last step describes techniques how to reduce number of resources that are loaded on osclass from plugins and theme. These are:

  • CSS files - style sheets
  • JS files - javascript

There exists some plugins like Minifier plugin for Osclass, but it's not recommended to use them. First and most important is that they are generating 1 file for CSS and JS on the fly - when site is loaded. This has no effect on site speed and is just trying to blame tools like Google Pagespeed that they are fast and has just very few resources.

One much more better is CSS & JS Minify Free Osclass Plugin that generates 1 css stylesheet and 1 javascript file and stores it - like a cache. This helps to minimize number of requests send to osclass as well as size of CSS and JS files. 

Another way is to manually merge plugin and theme files. Let's take a look what is the best way to do it:

  • analyze all your plugins you are using. Remove their stylesheets (enqueue function in index.php) and copy content of CSS to theme style sheet and content of JS to theme JS file, to bottom.
  • for external javascripts and stylesheets (usually minimized) create 1 css and 1 js, let's name them external.css and external.js. Put all the scripts and stylesheets to these 2 files and include them into your theme. Do not forget to remove their loading from plugins or theme's head.php (function register script).
  • this technique will cost you 1 hour, but helps you to reduce resources that must be loaded to maximum of six

No plugin is required to achieve this so it is no extra cost for you, but remember once theme or plugin is updated, it may wipe all your changes, so this is recommended just when you finalized whole development of your site and you do not plan to update/modify it in short term period.

 

Summary

Remember that tools like Tools Pingdom or Google Page speed may help you to analyze your osclass, but you may not be able to optimize all the aspects these tools are suggesting to you. What is most important when improving load time on your classifieds is that when you open it, it loads in 1.5 second no matter what tools tell you.

 

653 views