server.stat-cache-engine option

stat() system call caching; lighttpd can utilize FAM/Gamin to cache stat call.

possible values are: "disable", "simple", "fam", "inotify", or "kqueue".

  • "disable"
    no stat() call is cached (a single request might result in 3-4 stat() calls)
    If your files are changing in size a lot, you might have to have the stat-cache
  • "simple" (default; recommended)
    cache each stat() call for one second.
  • "fam"
    if FAM or gamin are installed and lighty is linked against those libraries you
    can use them to control the freshness of the stat-cache.
  • "inotify" (since lighttpd 1.4.56)
    On Linux, inotify() is used instead of FAM or gamin (which use inotify() on Linux)
  • "kqueue" (since lighttpd 1.4.56)
    On *BSD, kqueue() is used instead of FAM or gamin (which use kqueue() on *BSD)


server.stat-cache-engine = "simple" 


Caches have limitations. There have always been limitations with lighttpd stat_cache. If using server.stat-cache-engine with any engine, there are caching effects and tradeoffs. Still, for typical use cases server.stat-cache-engine = "simple" is recommended.

lighttpd stat_cache monitor only monitors directories with "fam", "inotify", or "kqueue". If a path is a symlink to a directory, lighttpd monitors the target of the symlink, the directory, so do not use server.follow-symlink = "disable" with server.stat-cache-engine set to "fam", "inotify", or "kqueue". Also note that in this case that lighttpd might not be monitoring the directory containing the symlink (which points to a directory elsewhere).

lighttpd stat_cache monitor is notified about additions and removals of files within a monitored directory but depending on the OS implementation of FAM or gamin (e.g. inotify or kqueue), lighttpd might not be notified of changes on files within a directory such as timestamps (touch), ownership, or even changes in contents (e.g. if a file is edited through a hard link).

server.stat-cache-engine = "disable" should be used when files should not be cached. Full stop. Similarly, "disable" is recommended if files change frequently.

On *BSD and using kqueue() on directories, any change reported results in clearing the stat_cache of all entries for that directory, since monitoring only the directory does not indicate which file was added or removed. This is not efficient for directories containing frequently changed files.

See Also

Updated by gstrauss 26 days ago · 11 revisions