Fastpath

From AOLserver Wiki
Revision as of 13:35, 19 August 2008 by Tigre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Mostly by Tom Jackson

The purpose of the API is to return a static file. Fastpath is designed to support return of smallish static content. It isn't some ancient way of speeding up stuff that was slow, it was for speeding up stuff that was already fast but was easy to make even faster.

If you want to avoid use of fastpath for dynamic content, just set the configuration lower than your dynamic content:

#
# Fastpath
#
ns_section "ns/server/${server}/fastpath"
ns_param cache                [set cache 10] ;# size per entry or number of entries??
ns_param cachemaxsize         [set cachemaxsize [expr 5 * 1024 * 1024]]
ns_param cachemaxentry        [expr round(floor($cachemaxsize/$cache))]


Or, if the dynamic content is very small, or customized, don't write it to a file in the first place. In general you are probably doing something wrong if you write small content to a file and immediately delete it. You are also likely doing something wrong if you are caching large files.

Cache keying

Fastpath uses a combination of mtime, inode, and size as its unique key.

Cache conflicts

There are situations where this could produce unexpected results. If a file served by fastpath is deleted and the inode is reused for a file with the same size whose mtime ends up being the same (either because it was created in the same second as the other one was last modified or through some file recovery mechanism such as tar or zip) regardless of filename the contents of the old file would be returned by any mechanism using Fastpath, such as ns_returnfile.