Smart Cache has been optimized for minimal RAM and CPU use. In normal use (by single browsing user), it requires only about 400Kb RAM from JVM. To get total size of required memory, you must add the shared dynamic (DLL) code loaded by the Java Runtime itself, which depends on Java versions, Java runtime options and operation system used.
On Linux with JDK1.1.7 and disabled Motif Java interface (export
NS_JAVA=true
), you will need only about 2.2MB of physical RAM (green
threads without JIT) or 2.7MB of physical RAM with tya JIT. When Smart Cache
is in heavy use by multiple users add 350-500k.
On OS/2 Smart Cache takes about 3.5-4.5MB RAM, it can be reduced by 2 using LXOPT utility on Java's DLLs. LXOPT utility is freeware now.
Smart Cache runs quite fast. After hand optimizations it is 5x faster than before and on OS/2 is even faster than Apache's proxy cache. On Linux, when JITed, it is comparable to other proxy caches coded in C (such as wwwoffle, but excluding Squid VM, which caches last accessed pages in RAM, this is 3-5x faster and uses a lot of memory. Squid has entire cache indexes in memory, while SC must load them from disk. Also this benchmark has nothing to do with 'realistic' proxy cache use).
On my 486/33DX System with 20MB RAM running JDK1.1.4 under OS/2 (JIT off), Smart Cache serves 350 pages/min (with JIT is under OS/2 about 25% faster, but sometimes crashes due to JIT bug), (Apache 1.1 only about 250). On Linux system with JDK1.1.7 with tya1.1 JIT and green threads it serves 910 pages/min. Do not use native threads under Linux's Java 1.1, it is buggy, slow and memory hungry.
One active browsing user needs about 50-60 pages/min (if network bandwidth is not a limiting factor). So 486/33 with Linux can serve 15 users without problem, if there is sufficient amount of RAM (20MB) and machine do not run any CPU-intensive tasks on normal or high priority.
I do not have access to faster machine, so I can not tell you any "more realistic" numbers. One my friend has Warp v4/SC setup on 486/66/32MB and runs 500MB cache for his 20 users on 128KB line. GC is running every night.
This is the setup for the web forwarder from www.firma.cz to www-orig.firma.cz. Smart Cache runs on www.firma.cz and forwards requests to www-orig.firma.cz. Some people use term web accelerator instead forwarder.
Web forwarders are useful for example if you need to maintain your WWW site locally, but have a slow line and many users, so put the forwarder on the ISP backbone, people will use forwarder, and forwarder will send back cached data from your server. Forwarder is also good when website uses dynamicaly-generated web-pages. If you have many users then many same pages must be generated for every request, which uses valuable CPU resources.
BindAddress * Fail * Pass http://www-orig.firma.cz/* default_forward_for www.firma.cz Redirect http://www.firma.cz/* http://www-orig.firma.cz/* access_log http://www.firma.cz/* firma.log NoCaching */cgi-bin/* default_refresh_pattern 15 60 0.20 5000 pragma_no_cache 0
Smart Cache can be also used in transparent-proxy mode. Unlike Squid, Smart Cache does all security checks and you will not open new security hole. You don't have to setup anything in scache.cnf, but you need TCP/IP stack or router hardware/software, which allow transparent proxying. Linux or Cisco operations systems can do that.
TCP-IP must be configured to redirect all traffic with destination port 80 to your Smart Cache's input port (same as for normal proxy requests). This configuration is operation system dependent, ask your network administrator for doing it.
In Linux, this is done with ipfwadm/ipchains programs.
Some Web sites deal so called "cookies". These "cookies" are tags sent from the server to the browser, which enable the server to keep track of the sites that the user visits, and thus compromise his privacy.
As was requested by many users, Smart Cache has now built-in filter for Cookies. After reading some documents about cookies, I decided to implement outgoing cookies filter instead of incoming. Benefits of this solution:
Drawbacks:
DANGER: When using wafer option (cookies filter itself do not harm), you can CRASH remote WWW site when sending back very long cookies (buffer overflow attack) or cookies with known name, but unexpected value (for example text instead of numeric input). Some versions of Microsoft Internet Information Server will crash entire (instead of just one http-child in apache), so no new users can access this server until IIS is restarted.
Change working directory to smartcache_home/src and execute command javac -O *.java
Java versions, starting from 1.2 (JVM Kaffe also do that), can run Java applications more easily. You can make .jar file and run it from command line or in Windows by double clicking on it.
Because .jar file is just renamed .zip file, you can also rename file MANIFEST.MF in SC archive to MANIFEST/MANIFEST.MF and pack compiled classes with this file using any .zip utility.
Now you can run scache.jar via java -jar scache.jar or by double clicking on it.
BindAddress is default set up to 127.0.0.1. Many people do not need access SmartCache from others computers and this also closes access from Internet to your computer or LAN via Smart Cache, which is a Good Thing. No other computers can connect to it. This is very good for security, but not very useful if you have LAN.
If you have an Intranet and want to allow other Intranet computers to connect, enter your Intranet IP address here.
Magic '*' allows any computer (even from Internet) to connect and use your proxy. If you use it, blocking some URLs in you private network will be wise (see URL blocking, Section 5.6). There are no known security holes.
For fine-tuning access to your proxy server see Proxy access control, Section 7.14.
Technical notes:
Structure of .cacheinfo files (Version 3)
Following OLD format of .cacheinfo files is used in SC from version 0.30 to 0.46.
Structure of OLD .cacheinfo files (Version 2)
Smart Cache can produce different types of logfiles, this is especially written for use in Web forwarding with Smart Cache, Section 7.3, but logs can be produced even if no forwarding is set. Logs are wildcard masked, so you can log to multiple logs of one type at once.
Usage: logfiletype mask filename
logtype can be : access_log, agent_log or referer_log.
referer_log can be switched to compact mode by full_referer_log 0 which is more usefull for eyes-browsing.
access_log * C:\SCACHE\LOGS\ACCESS.LOG referer_log * C:\SCACHE\LOGS\REFERER.LOG full_referer_log 0
If you are using SC for offline browsing, sometimes you may find importing files from outer sources (for example some CDs has offline copies of some servers) useful.
Place these files to directory structure, which has the exactly same name as original URLs of files. For example in /tmp make directory /tmp/www.javaworld.com/javaworld/jw-10-1999/ and copy necessary files to it, you can create any number of directories (even from different servers).
After that run java scache -import /tmp and files will be imported.
Smart Cache will check if newer version of imported file is not already available in cache. If not, file will be moved (preserving timestamp) to cache, if it fails, because file and cache directory are at different filesystems (disks), SC will copy file instead. Is wise to place files to the same filesystem as SC main data directory and clear READ-ONLY attributes.
When Smart Cache gets request for unknown protocol (for example ftp) and http_proxy is set, SC will forward this request and cache received result. See also Smart Cache limitations, Section 10.3.
SC by default uses 4x4 swap directory levels. If you look into it and see, that there are many (about 100) subdirectories with server names it may be wise to increase swap_level1/2_dirs and than redistribute directories to new levels using -rebalance command line option.
Proxy access may be limited by using "allow" configuration statement with the host ip address as a parameter to grant access only to specified hosts. Hosts that are not allowed to access proxy server will receive "403 Cache access denied" response. If no "allow" statements are found then any host is allowed to access the proxy.
Example: # allow proxy access only from computer it is running at and from addresses # 192.168.1.2 and 192.168.1.3 allow 127.0.0.1 allow 192.168.1.2 allow 192.168.1.3
A parent proxy login and password may be specified in the "http_proxy" configuration statement after the parent proxy port in a form login:password.
Example: http_proxy my.cache.net 3128 mylogin:mypass
Cached data can be easily exported from Smart Cache. Data are exported in format, which can be used in Importing files to Smart Cache, Section 7.11.
Smart Cache can export last recently cached data in 3 modes:
Command line syntax is -[lru|full]export <Directory> <Timedelta>
Time delta is in format number unit with no space. (For example "1w" is one week). Supported time units are: d/D day, w/W week, m minutes, M months, y/Y years, h/H hours.
Smart Cache can compress incoming text data, which save significant amount of
diskspace. If you want to do this set auto_compress 1 in
scache.cnf
.
These data will be sent to your browser in gzip compressed form. Your browser must know how to decompress them. Existing data can be compressed via Smart Cache repair utility, Chapter 9
If you see garbage on the screen, your browser can not handle compressed data. If you want still to use data compression set auto_decompress 1. Smart Cache will decompress data if your browser do not sent accept-encoding: gzip header. Some browsers do not send this header, but accept compressed data, so use auto_decompress only if necessary.
Browsers which supports compressed HTML pages:
Browsers which DO NOT SUPPORTS compressed pages:
I have no information about browsers on other OSes (Win,Mac). If you want, you can send me these informations.
hsn@cybermail.net