The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

NetPositive: Clear your cache automatically

Contributed by: Justin Sherrill
This tip is valid for: Both BeOS and Haiku

[Editor’s note: NetPositive 2 has much better cache-handling features. Upgrade and you won’t need this tip!]

NetPositive’s cache will get large if you don’t trim it, but who wants to have to check repeatedly? It’s possible to have the cache files erased on startup, but that can be a pain if you reboot often or don’t use your computer for extended periods.

The following chunk of code, when placed into your UserBootscript (/boot/home/config/boot/UserBootscript) will clear NetPositive’s cache on startup, but only when it exceeds the size in K specified as “max” below, which is currently set to 4 megabytes in this example.

let max=4096
let size=`du -s $HOME/config/settings/NetPositive/NetCache | cut -f1`
if [ $size -gt $max ]; then
rm -f $HOME/config/settings/NetPositive/NetCache/*

Posted in Applications

(comments are closed).