cache management controls are split between the Global Configuration Manager, the System - Cache plugin, and the individual module parameter controls.. Extensions Directory includes a su
Trang 1Managing
Performance and
Accessibility
IN THIS CHAPTER
Understanding cache management Improving content performance Tuning Joomla! performance Enhancing accessibility
The performance and accessibility of your site should be common
con-cerns for all web site owners This chapter looks at how Joomla! can
be optimized for better performance and how the accessibility can be
improved through good management of templates and content items
Although it may initially appear that no positive relationship between
perfor-mance tuning and web site accessibility exists, the opposite is true Many of
the items that improve the performance of a Web site are also consistent
with improving the accessibility of a Web site Indeed, the bells and whistles
that many site owners include in their sites can limit both the site’s
perfor-mance and its accessibility
Understanding Cache
Management
Cache files are temporary files created and stored on the server that help to
cut down on server load and improve performance times When a file is
cached, the server can display the cached value instead of going through the
effort of calling up the information from out of the database and assembling
it for display When site traffic is heavy, the efficiency gained through
cach-ing can result in dramatic performance improvements
Joomla! supports both global site caching and the ability to control caching
for individual modules You can also set the length of the time things are
cached, which tells the system how long to hold something before refreshing
it In some situations, for example when you install an updated component,
you may want to dump your cached data in order to force the system to
Trang 2update the information in the cache The Joomla! admin system gives you the ability to flush the cache either completely or selectively
The Joomla! cache management controls are split between the Global Configuration Manager, the System - Cache plugin, and the individual module parameter controls In the sections that follow, all three options are discussed, as well as how to clean and purge your site’s cache
Tip
If you are looking for more cache control, consider installing a third party extension to expand this functional-ity The Joomla! Extensions Directory includes a sub-category dedicated to enhanced caching: http:// extensions.joomla.org/extensions/site-management/cache
Setting the Site cache
In the default configuration, caching is turned off The global site caching settings are located in the Global Configuration Manager, as shown in Figure 26.1
FIGURE 26.1
The Joomla! 1.5.x Global Configuration Manager’s System tab, showing the Cache Settings
Trang 3To enable caching, follow these steps:
1 Log in to the admin system of your site.
2 Access the Global Configuration Manager by either clicking on the Global
Configuration icon on the Control Panel or by clicking on the Global Configuration link under the Site menu The Global Configuration Manager loads in your browser.
3 Click the System link The System tab opens in your browser.
4 Set the Cache option to Yes.
5 Click the Save icon The system enables caching.
Tip
The default cache time is 15 minutes Setting the Cache Time option in the Global Configuration Manager to longer times results in improved performance, but it also means that the site will be serving older content The decision of what is the right cache time for your site balances on the trade-off between performance and time-liness If your content changes frequently, the cache time value should be low If your content changes rarely, then you can safely set it to a higher value.
Setting the System – Cache
The System - Cache plugin provides another global caching alternative, in this case, page caching The plugin is disabled by default Access the plugin by going to the Plugin Manager under the Extensions menu Clicking on the option named System - Cache will open the plugin for editing,
as shown in Figure 26.2
To enable page caching, follow these steps:
1 Log in to the admin system of your site.
2 Access the Plugin Manager by clicking on the Plugin Manager link under the
Extensions menu The Plugin Manager loads in your browser.
3 Click the System - Cache plugin The Plugin Editing dialogue opens in your browser.
4 Set the Enabled option to Yes.
5 Click the Save icon The system enables page caching.
Note
You can also enable browser-side caching for your site’s pages by setting the Use Browser Caching Plugin parameter to Yes.
Trang 4FIGURE 26.2
The System - Cache plugin
Caution
Page caching is the most aggressive form of caching offered by the default Joomla! system You should test your site after enabling page caching, testing in particular the impact on front-end functionalities such as the Random Image module, the Newsflash module, and the log in and log out process If you have installed any third-party extensions, make sure that you also test those after enabling the System - Cache plugin If you observe problems, disable the plugin and test again.
Setting the module cache
Because the cache serves up “old” content, that is, content that has been stored rather than pro-duced live, some items should not be cached Banner and image rotators, login functionalities and the like are typically excluded from caching In those situations where you want to exempt items from the global cache settings, or you want to change the length of time the information for a
Trang 5FIGURE 26.3
A typical module cache setting, in this case for the Random Image module
In the default Joomla! 1.5.x system, caching is disabled in the following modules:
l Banners (the Advertisement module only in the sample data)
l Feed Display
l Newsflash
l Random Image
l Related Items
l Statistics
l Wrapper
Caching is not an option for the following modules:
l Breadcrumbs
l Login
l Syndicate
l Who’s Online
Trang 6Module caching parameters typically include two options for users You can choose to use the Global Cache settings, as defined in the Global Configuration Manager, or to exempt the module from that setting The second option is to set the cache time for the module, though this option is not available for all modules
Cleaning the cache
Cleaning the cache wipes out the cached files and forces the system to refresh the cached informa-tion If you have updated an important content item, or installed a new module or component, you will probably want to clean the cache and get the updated information showing on the site Joomla! includes a cache cleaner that is accessed from within the admin system Simply click on the option Clean Cache under the Tools menu The Cache Manager will load in your browser, as shown in Figure 26.4
FIGURE 26.4
The Cache Manager - Clean Cache Admin screen, in this case showing the Site tab
Trang 7The toolbar at the top of the Cache Manager - Clean Cache Admin screen provides quick access to the following functions:
l Delete: Select one or more items from the list, then click this icon to delete the items In
this context, deleting an item means deleting only the cached files
l Help: Click to access the online help files related to the active screen.
Below the toolbar are two links: Site shows you the Site items that are cached Administrator shows you the Administrator items that are cached
The main content area of the screen contains a list of all the cached files for your site The columns provided are:
l #: An indexing number assigned by Joomla! This number cannot be changed.
l Checkbox (no label): Click in a checkbox to select an item; this is needed if you want to
selectively delete items from the cache
l Cache Group: The type of item being cached Note that the name here reflects the name
of the subdirectory where the cached item is kept on the server
l Number of Files: The number of files in the cache group.
l Size: The total size of the files cached in this group.
Finally, at the bottom of the screen, below the content area, is the Display # option Change the value in the combo box control to alter the number of items that are displayed on the page The default value can be altered by changing the List Length option on the Global Configuration Manager
To clean up your site’s cached files, follow these steps:
1 Log in to the admin system of your site.
2 Click on the Clean Cache option under the Tools menu The Cache Manager - Clean
Cache Admin screen loads in your browser
3 Select the checkbox next to the items you want to delete, or click the top checkbox
to select them all.
4 Click the Delete icon The system immediately deletes the cache files.
Note
Using the Clean Cache option deletes both the current cache as well as the expired cache files If you only want to free up some server space by cleaning the expired cache files, you can either use this option, or the Purge Expired Cache option discussed next.
Trang 8Purging the expired cache
The system’s caching mechanism retains expired cache files on the server When you use the Clean Cache option, you clean both the current cache and the expired cache files The system also pro-vides you with a separate option to clean up, or purge, the expired cache files, leaving the current cache files intact
To use this alternative cache cleaning tool, click on the option Purge Expired Cache under the Tools menu The Cache Manager - Purge Cache Admin screen opens in your browser, as shown in Figure 26.5
FIGURE 26.5
The Cache Manager - Purge Cache Admin screen
The toolbar at the top of the Cache Manager provides quick access to the following functions:
Trang 9To purge the expired cache files, follow these steps:
1 Log in to the admin system of your site.
2 Click on the Purge Expired Cache option under the Tools menu The Cache Manager -
Purge Cache Admin screen loads in your browser
3 Click the Purge Expired icon The system immediately deletes the cache files.
Note
Using the Purge Expired Cache option has the advantage of not causing a dip in the front-end site performance
If your site sees heavy traffic, using the Clean Cache option can cause a performance dip because the system must rebuild the cache after you force it dump the files Purge Expired Cache only kills off the expired files, leaving the current cache files untouched Typically this is only an issue if your site has numerous users active
at the time you decide to clean the cache.
Improving Content Performance
Everything that is on the pages of your web site has an impact on the site’s performance If you build large pages with large files, the page loads more slowly than a smaller, lighter page While the pages your Joomla! site generates from components are largely beyond your control, you can have a significant impact on your articles pages If you work smart and keep in mind the need to build lean pages, you can serve web pages to your visitors more quickly and also reduce the bur-den on your server Never forget, it all adds up If you have multiple visitors on your site simulta-neously, the page each is viewing contributes to the load Saving a few kilobytes in file size here and there can add up quickly
The following sections explain the issues you should consider when creating content for your site
Avoid large files
Large file size is most commonly an issue with graphical files inserted into articles Optimize your images to keep file sizes down to reasonable levels As image file size is at least partially a byprod-uct of the physical dimensions of the image files (width and height), it is hard to say what is right for your site; however, a reasonable goal is to keep your images under 50K in size If your images are too large to achieve that goal without a loss in quality, you may want to consider whether you need to display large images on the page, or perhaps you should consider whether a better course would be to display a smaller image, a thumbnail, that is clickable to open a larger image Note also that for the web, image resolution of 72 dpi is sufficient; anything higher is overkill and unlikely to be reflected in the user’s monitor