Caching

 
What it does

It saves the rendered html content of the widget in .../wp-content/cache/wppa-widget/, and the rendered html content of the shortcode in .../wp-content/cache/wppa-shortcode/ when it is initally requested by a visitor opening the page where the widget or shortcode appears. This code is re-used when needed and still up-to-date; hence saving the servers cpu and dramatically reducing the number of database queries.

How to activate

The widgets have a selection box on the activation screen:

Select cache expiration time (min):

Select --- none --- to disable caching, --- infinite --- for fully smart caching

You can now safely select --- infinite --- to activate caching the widget, because the caching mechanism is 'smart'; i.e. the cached files are cleared when it is likely that the content to display would be changed.
Only a few widgets do not have the caching option, these are widgets of wich the content is visitor dependant e.g. the Notify Me widget.

The WPPA shortcodes have a new attribute: cache="". You can enter a number (minutes) between 5 and 60, or the word inf; e.g. cache="30" for half anhour or cache="inf" for fully smart caching.

How it is implemented

When a page is opened by a visitor, a check is done to see if caching is on and the cache file does not exist or the cache file is expired (i.e. older than the expiration time). If so, it is removed and re-created, saved and added to the page output.
Whenever a new photo is uploaded, a comment is added or a rating is changed, the cachefiles are removed, so they will automatically be re-created when the respective widget or shortcode is to be displayed again.
Also, when a page or post is saved that contains the text [wppa or [photo - i.e. a WPPA shortcode, the cache is cleared.
As a last resort, whenever you change something that would influence any wppa display with a change not accounted for yet, there is the admin menu item Clear cache to clear the cache 'manually'.