Author Archives: admin

Improving Page Loading Times for Web Developers

If your WordPress or Magento website is slow to load, you will lose a lot of visitors because of this. Most web surfers are impatient, and are not going to give you long to impress them before they hit the back button and go to the next site in the search results. If you want to impress your visitors, you must optimize your site to load as quickly as possible. Here are a few tips:

Compress Images

Optimize your images for your site. Use the best compression you can without sacrificing quality. Create small thumbnails for images shown in-page, and allow the user to click those thumbnails to view uncompressed, full size images in a lightbox if they so desire.

Minimise Redirects

Remove tracking code or off-site widgets if they have a large number of redirects. Host as much of your website’s content as possible on your own servers or a reliable CDN. In addition, try to minimize the amount of off-site JavaScript on your pages. Keep your designs simple, and make sure that it will be functional even if some off-site content fails to load because of unexpected provider downtime.

Turn on Compression

Use mod_deflate module to compress HTML, XML and CSS. In many cases you can reduce HTML content to just 1/5th of its original file size by enabling compression on your server. The performance overhead is minimal, and in a world where bandwidth is the main bottleneck it makes sense to use CPU power to reduce bandwidth consumption.

Serve Different Pages for Different Devices

Take advantage of browser and platform detection capabilities to serve different pages for mobile, desktop and tablet devices. Serve super-high resolution images to iOS devices with retina displays, and offer lower resolution images for smaller mobile devices. If possible, also use different layouts for touch screens vs keyboard+mouse interfaces.

Using Mod_deflate For Bandwidth Reduction

Mod_deflate is an Apache module which can be used to compress files before sending them to clients. If configured correctly, mod_deflate can offer substantial bandwidth savings.
Mod_deflate can be used to compress HTML, CSS, XML and other text files, reducing page loading times for users and reducing your server’s bandwidth consumption. There is some small performance overhead for compressing files, but on modern servers the overhead should be negligible compared to the reduction in loading time from the file size reduction.

Setting Up Mod_Deflate

In most cases, mod_deflate comes with Apache2 platform, so all you have to do is enable it, and then restart Apace2 by entering the following in the command line:
a2enmod deflate
/etc/init.d/apache2 restart
The above instructions are for Debian and related distributions (e.g. Ubuntu). If you are running a RHEL distribution you may need to edit Apache’s configuration files manually and add deflate_module to the LoadModule section of the file.
The next step is to configure mod_Deflate. In most cases, you should only compress text and HTML files. Add the following to your config file to do this:
AddOutputFilterByType DEFLATE text/html text/plain
Another option is to set up mod_deflate to compress all files, except for files which are explicitly excluded, such as already compressed ZIP files. There is no point attempting to compress a ZIP or TAR.GZ file because these files have already been compressed once and it is unlikely that you would save much (or any) bandwidth by compressing them again.
Once you have finished configuring mod_deflate, you should restart Apache again. The compression occurs silently. If you want to see how well it is working, you can enable logging on mod_deflate, request a few files, and then open the log file to see a report of how well each requested file was compressed.

REST and oAuth for Magento Developers

REST functionality has been a part of Magento since version 1.7. Older versions of Magento supported only SOAP and XML-RPC implementations. While you can still take advantage of SOAP and XML-RPC functionality in newer versions of Magento, it is well worth learning how to use REST services in Magento.

Using oAuth and the Magento API

To consume REST services in Magento, you must use oAuth for authentication. To do this,y ou must create an oAuth consumer, and obtain an oAuth token for the service which you would like to consume. Tokens can be found under the System > Web Services section of the Magento admin panel. Using oAuth offers an added degree of security because the user does not need to provide their direct Magento login details to a third party App, and can revoke an app’s rights to access the services at any time.
There are three REST consumers which can access resources under the Magento API, these are:
• Guest – a front-end user who is not logged in
• Customer – a front-end user that is logged in
• Administrator – a user that is logged in to the back end.
Each REST consumer has different roles, and has different capabilities. For example, a customer may be able to create, retrieve, update and delete their own address and manage their orders, while a non-logged in frontend user or programmer would only be able to retrieve product listings and view certain parts of the site.
The REST implementation allows two possible actions on each resource – writing and reading. A guest may only read, a customer has read access to most resources and may have limited write capabilities. Administrators can read and write to any resource.
REST Apps are listed in the REST My Apps section of the admin panel. Users also have a My Apps section on their account page, which allows them to manage oAuth apps that they have authorised to access their accounts.