Saving Server Resources

HWimage has built in Resource Savers

As some users have found out and others have asked, on extremely busy site HAMweather can use a good amount of server resources, because the cgi script has to run upon every request. Well with this in mind , it should be noted that since HWimage is an add-on to HAMweather PRO, it will use slightly more resources than HAMweather Pro. 

To help battle the Server Resource issue several things have been implemented into HWimage:

  1. HWimage has two modes, the first being the basic mode that outputs a 'stock' image of either the zone or current conditions.  The second mode being the Advanced mode which allows you to create custom images from HWimage template.

    The basic mode is the most efficient of the two mode.  This is because it creates a small stock image. With the advanced mode HWimage must actually parse through the template file which takes slightly more time and resources.  So when using HWimage, thought should be given to using the basic mode.
  2. HWimage implements a caching feature (on top of the normal HAMweather caching).   HWimage will actually cache an image after it is created the first time.  Then for all requests for the same image HWimage will redirect the users browser to the cached image, until the images weather data expires.  This caching method helps decrease server resources greatly due to the fact the not all the HWimage libraries need to be loaded, and no image need to be created.

    You do not need to worry that HWimage will use bad weather images. When a forecast is requested , HWimage checks to see if the main weather data stored in HAMweather's cache is good if so it then check to see if the cached image is newer than the cached weather data if so it uses the cached image.  If the cached weather data is expired or the cached image is older than the cached weather data HWimage will create a new image and store it in the cache.

You can Save resources as well

The caching capabilities of HWimage do help to tremendously drop the amount of server resources used, especially on the busier sites. But there are other things that can be done to drop server usage even more.

If you plan on using a limited number of HWimage images in your site, but the site is a busy one then you may want to actually create the images from an automated cron job which save the images to a file and then link directly to the saved images in your web pages.

The benefits form this method are that the HWimage script no longer needs to be launched at every page request, for the page will link directly to an image, thus dramatically lowering resources.

For more information on how to run HWimage from the command line/cron job and have it save the images to files review the 'om' and 'of' parameters in the 'Output Image to file' Section of the documentation.