Caching

To achieve high performance, Nemesis Gallery extensively uses caching of generated results. In most cases you can simply leave the cache setup unchanged, as the settings should be sufficient for most scenarions. However, this document describes in detail how the caching is used and setup in case you need to modify it.

Output cache in general

Nemesis Gallery relies on the output caching, as implemented in ASP.NET and IIS 7. Output caching stores generated response (HTML or resized image) in memory for given amout of time. HTTP header is also added to output, instructing client not to request the data gain before the time elapses. When the same URL is requested again, is served from the output cache directly. Two main methods are used to support caching: variations and dependencies.
  • In variations, several versions of given data is stored, depending on the request. For example, for different query string values or used browser different cached version can be stored. Nemesis Gallery uses varyByParame - variations by GET or POST parameters.
  • Dependencies ensure that the item will be removed from cache, when source data will change (ie. file, folder or database). Nemesis Gallery uses file dependency on picture files. Dependencies however work only on server side - although server cache will be cleared, clients must do refresh for changes to take effect.

Caching implementation in Nemesis Gallery

All three outputs generated by Nemesis Gallery (thumbnails, information pages and directory listings) are output cached, by default for 60 minutes. You can change the time using the cacheTimeout attribute of appropriate element (see Installation and Configuration for description).

Caching of resized images (thumbnails)

Resizing of images is probably the most resource-consuming operation Nemesis Gallery performs. Cache is automatically dependent on physical file of master image. If you change the source image, server cache will be cleared immediatelly. Cache automatically varies by the Q parameter (in query string, specifies thumbnail size).

Caching of directory listing

Directory listing output cache depends on physical directory of which the listing is. When you add, remove or change any file or folder in this directory, the cache is cleared. By default, query string arguments are ignored (the same cached version is returned, regardless of query string parameters). If your template makes use of the query string parameters, set the varyByParams attribute of the directoryListing element to true.

Caching of information page

By default, information page depends on entire directory where the given image is located. Thus when any file in folder is modified, all individual image caches are cleared. This is because the template may take advantage of the prevName and nextName elements. They contain information about the "previous" and "next" relative file, in alphabetical order. If your info page template ignores these data (or if you don't care about that the data may be incorrect for time of caching), you may set the dependOnFolder attribute of the infoPage element to false and save some resources.

By default, query string arguments are ignored (the same cached version is returned, regardless of query string parameters). If your template makes use of the query string parameters, set the varyByParams attribute of the infoPage element to true.

Last edited Nov 9, 2008 at 10:46 PM by altair, version 2

Comments

No comments yet.