[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ A ] [ B ] [ next ]


Smart Cache Manual
Chapter 5 - Smart Cache operation


5.1 Smart Cache on Debian GNU/Linux

Smart Cache is default configured as follows:


5.2 Running Smart Cache

Starting Smart Cache is easy:

  1. change your current directory to Smart Cache's home directory, where the *.class files are in.

  1. execute the command java -cp . -ms1m scache

If all works right Smart Cache starts and you will see something like this:

     Smart Cache 0.41 - full featured caching proxy server and web forwarder
     Copyright (c) Radim Kolar 1998-9.  Open source software; There is NO warranty.
     See the GNU General Public License version 2 or later for copying conditions.
     
     Wed Sep 01 15:53:14 GMT+02:00 1999 Smart Cache 0.41 ready.

If it do not works, read Troubleshooting, Chapter 13.


5.3 Stopping Smart Cache/Shutdown flag

Smart Cache can be stopped following ways:


5.3.1 Killing process

Probably most convient method. Its also good for use in startup/shutdown scripts.

  1. Killing Smart Cache process. Please dont use hard kill (SIGKILL or kill -9) if possible. Smart Cache needs to sync .cacheinfo files before exiting. Use hard kill only if Smart Cache gets deadlocked.

  1. Closing Smart Cache window

  1. Pressing CTRL-C in Smart Cache window


5.3.2 Using flag file

Second method to stop Smart Cache is by creating flag file with name defined in scache.cnf. Flag file can be created on Unix systems with touch <filename> command. In Windows environment use for example

     echo > c:\name\of\shutdown\flag     or
     mkdir  c:\name\of\shutdown\flag

Flag file can have any content inside, Smart Cache checks only if some file with specified filename exists.

You might use directory with specified name instead of file (this is easier to create under Windows because its just one simple mkdir command). If you are using directory be sure not to place any files inside it because Smart Cache will not be able to delete it on shutdown and on next start it will shutdown again because flag directory still exists.

  1. If you want to shutdown cache after it becomes inactive use shutdown_flag and wait about 3 minutes. Smart Cache will shutdown without interrupting anything. If Smart Cache is still in use, it will continue running and stops after 3 minutes of inactivity later.

  1. Smart Cache can make also 'fast shutdown'. Configuration keyword immediate_shutdown_flag is used for it. Smart Cache checks presence of this flag every flag_check_interval seconds. Use this if you do not want to wait for shutdown via flag too long.


5.3.3 Background information

Smart Cache updates every 3 minutes .cacheinfo files, which holds information about directory contents. If .cacheinfo is bad, no (or some) files in directory with that .cacheinfo will be found.

If you look into SC output, you will see how many .cacheinfo files were updated in message XX - directories saved. If you see 0 dirs saved and you are not using SC, no .cacheinfo contains out-of-date information.

You can recreate .cacheinfo file by repair utility or more convient way is to run scache -repair.


5.4 Running garbage collection

If your cache is getting large, you may want to run the garbage collection process. [4] Smart Cache never deletes something from its data directory, it only adds or overwrites files. You must run GC or use other software tools for freeing disk space.

GC process scans the entire cache, finds old files and deletes them until specified cache size is reached. Detailed information in How garbage collection works, Section 7.3.

Garbage collections also checks cache integrity, deletes unreferenced files, empty directories and bad entries from .cacheinfo files. This check is the same as does -killunref procedure. Edit the gc.cnf file and run it with java scache -gc

Garbage collection can be run, while proxy server is still running, there is no need for stopping it. See also Configuration of garbage collection, Section 4.2 and Smart Cache maintenance, Section 5.5.


5.5 Smart Cache maintenance

Smart Cache needs no special maintenance except Running garbage collection, Section 5.4 and maintaining some free diskspace.

In some rare cases (mainly due to improper cache shutdown) there can be some orphan files (files without any reference) in the cache. These can be located and deleted using the java scache -killunref command or located and inserted back into cache (by creating reference for them) by java scache -repair. These files are very rare and takes very few diskspace (in most installations about 0.1%) , so there is no need to worry about them.

Nowadays these commands are obsolete and has been replaced by the garbage collector, which happily deletes them as part of his normal operation. Use these commands only if you want to repair cache without performing garbage collection. This operation is about 2-3 times faster than garbage collection.

Repair procedures summary:

  1. if you are short of diskspace use -gc

  1. if you are using -gc you need not to run something else

  1. if you are want to recover inaccessible files run -repair

  1. if you want to see what files will gc delete without deleting them use -fakegc. Very handy for fine tuning GC.

  1. do not use -killunref, it is just waste of time. Repair or GC does much better job.


5.6 URL blocking

Smart Cache has a builtin URL filter. This filter was designed to eliminate ADV. banners, because they slow down browsing a lot, and other unwanted stuff which WWW browsers downloads without asking (for example .AVI files in web pages. Netscape downloads it even if do not have plugin for them.).

Filter comes in two flavours normal MS-DOS like regexp and full posix like regexp. Full regexp filter has higher priority than normal and is configured in file rfail.cnf.

Normal filter in controlled by two fail.cnf and pass.cnf configuration files. In first file, you can find list of BLOCKED URLs and list of UNBLOCKED in second. Files has the same syntax - write one URL mask per line, you can use wildchar '*' in expected way. SC will detects when you edit this files and reload it without needing to restart.

When SC gets request for a particular URL, it will look in pass.cnf first. If requested URL is one of them, SC will skip following tests and displays it. If requested URL is not found in pass.cnf SC will look into fail.cnf. If requested URL is there, SC will abort request otherwise request will be allowed.

When SC encounters a blocked URL, error 403 Forbidden by rule will be displayed. You can display any custom URL instead, many people uses some images, which will appear on places of ADV. banners. You can use any picture from net, SC will cache this, so it will not be downloaded more times.

     ErrorDocument 403 http://some.site.with.nice.images.com/images/nature/bluesky.gif

Other people likes blank image instead. Famous 43 byte long 1x1 transparent GIF is now hardcoded in SC and can be used with:

     ErrorDocument 403 0

In some cases you may got unwanted Forbidden by rule errors. You have two choices for their eliminating:

  1. You can locate URL mask which causes the URL blocking and remove it from the file. (trace_fail yes helps, if in trouble)

  1. Because this URL masks blocks also what you want to block (for example ADV. Banners), You can add new mask to pass.cnf file which unlock incorrectly blocked URL.

Example: You want to access site http://ad.astra.com/, but you can't do that because Smart Cache has a default entry http://ad.* in fail.cnf file, which deny access to this server. You do not want to remove this entry from fail.cnf, because it unlocks many ADV. banners. Solution is add http://ad.astra.* to pass.cnf file.

You can also turn of announcing blocked URLs to console by directive trace_fail. This is useful if you are using a complex "fail.cnf" with a lot of entries and can't fiddle out if or why some request has been blocked.


5.7 Smart Cache GUI

Smart Cache has a simple HTML user interface, which allows to search and browse the cache content. This UI is required if you want to use special offline support features (hooks for Smart Cache Loader). To enable it, add ui_port 8081 to scache.cnf. After that point www browser to http://127.0.0.1:8081/


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ A ] [ B ] [ next ]


Smart Cache Manual

0.94

Radim Kolar hsn_nospam_at.sendmail.dot.cz