[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ 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

If you installed the JRE1.1 start Java with jre -cp . command instead only java . If you are installed JDK1.3 or higher you can add switch -server. (Note: You can also make .jar file see Making Java 1.2+ .jar file, Section 10.1 and run it by java -jar scache.jar or by double clicking on .jar file) All other parameters remain the same.

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 -ms1m scache

If you want to Smart Cache runs faster at cost of using more memory -- Change -ms1m switch to something else. See Proxy cache Benchmarks, Section 9.2

If all works 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, try Troubleshooting, Chapter 13.


5.3 Stopping Smart Cache/Shutdown flag

This is the most obscure feature of SC. You do not need to understand what it does or even use it. Everything can be killed by CTRL-C, Close Window, Kill process or CTRL-ALT-DEL on newer Windows versions.

If you want to cleanly shutdown cache - just create a file (or directory) with name as set in the shutdown_flag and wait about 3 minutes. This makes clean shutdown of SC without interrupting anything. If Smart Cache is in use, it will continue running and stops after 3 minutes of inactivity.

Smart Cache can make also 'fast shutdown', which is still better than killing the Smart Cache process (CTRL-C is also killing, Java can not hook it), because it synces directories information and logfiles. Configuration keyword immediate_shutdown_flag sets the name of this flag file and keyword flag_check_interval sets, how often (in sec.) SC checks for this flag. Use this if you do not want to wait for normal cache shutdown.

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 is nothing special, SC checks only if some file with specified filename exists. Directory with specified name can be also used (this is easier to create under Windows).


5.3.1 Background information

Smart Cache updates every 3 minutes .cacheinfo files, which holds information about directory contents. If .cacheinfo is bad, no/some files in directory will not be found, but you can recreate them by repair utility. If you look into SC output, you will see how many .cacheinfo files was 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, so you can kill SC process without harming anything. Also if you are just browsing offline, only outdated information in .cacheinfo files is Last Access Date, which is used only by GC, so killing SC will not harm your data.


5.4 Running garbage collection

If your cache is getting large, you may want to run the garbage collection process. [5] Smart Cache never deletes something from its data directory, 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 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 got 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 ] [ 17 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ next ]

Smart Cache Manual

0.84
Radim Kolar hsn@cybermail.net