When I first came into contact with the web cache, I knew nothing about it. Later I learned about the categories of web Cache through searching, including database cache, application layer cache, front-end cache, and client cache. The database cache can be used for "space for time. For example, to create a table to store the total number of data records of another table type
When I first came into contact with the web cache, I knew nothing about it. Later I learned about the categories of web Cache through searching, including database cache, application layer cache, front-end cache, and client cache.
Database cache
This can be used for "space for time. For example, if you want to create a table to store the total number of data records of another table type, you can update the data table and the number of statistical records each time you update the data. When you need to obtain the number of data items of a certain type, you do not need to select count to query. You can directly query the statistical table, which improves the query speed and database performance.
Application Layer Cache
The Application Layer cache has the greatest relationship with developers and is frequently used.
. Cache the query results of the database to reduce the data pressure. This must be done on large websites.
. Cache disk file data. For example, common data can be stored in the memory without reading the disk every time, especially intensive computing programs, such as word segmentation.
Cache a time-consuming computing operation, such as data statistics.
Application Layer CacheArchitectureIt can be divided into several types:
. Embedded, that is, the cache and application are on the same machine. For example, single-host file caching and hashMap in java for data caching. This cache speed is fast and there is no network consumption.
. Distributed cache, the cached data is independent to different machines, through the network to request data, such as common meMcThis is what ache is.
Distributed cache can be divided into several types:
Splitting data by application to different cache servers is a simple and practical method.
. Store Data to different cache servers according to certain rules (such as hash, route, and so on ).
In proxy mode, applications are transparently processed by the proxy when obtaining data, and the cache mechanism is handled by the proxy server.
Front-end cache
The front-end cache we mentioned here can be understood as a general useCdN technology, using squIdFront-end Buffer technology, mainly for staticFile. Html 'target = '_ blank'>File TypeStatic files such as video, css, js, and html.
Client Cache
The browser-side cache allows users to directly read data from the local cache after one request, but not from the server for the next request. This reduces the server load and speeds up user access.
The squid used here is the scope of the front-end cache. squid implements the following proxies: normal proxy (relative to transparent proxy), transparent proxy, and reverse proxy. Normal proxy and transparent proxy are often used to accelerate client access to the Internet and client access control, while reverse proxy is often used for server acceleration and security control, install the squid kit by compiling to learn more about the squid proxy.
This experiment is the first step in this series of learning.
The squid version adopted by CentOS 5.5 on the operating platform is squid-3.1.16. The functions to be implemented are normal proxy implementation and squid Web page management implementation.
The preparation kit to be installed is
Gcc, make, ssl, openssl, openssl-devel, mod_ssl
The above kits can be installed in yum and rpm of the system.
First, the compilation and installation of the suite
[Root @ localhost ~] # Ll squid-3.1.16-20111022-r10388.tar.gz
-Rw-r -- 1 root 3399757 Oct 24 squid-3.1.16-20111022-r10388.tar.gz
[Root @ localhost ~] # Tar zxvf squid-3.1.16-20111022-r10388.tar.gz
[Root @ localhost squid-3.1.16-20111022-r10388] #./configure -- prefix =/usr/local/squid --Enable-GnuregEx-- Enable-arp-acl -- enable-auth = "basic" -- enable-basic-auth-helpers = "NCSA" -- enable-asyNc-Io = 80 -- enable-storeio = ufs -- enable-ICmp-- Enable-Kill-Parent-hack -- enable-snmp -- disable-ident-LookUps -- enable-cache-digiests -- enable-ssl -- enable-delay-pooLs-- Enable-poll -- enable-linux-netfilter -- enable-underscore -- enable-err-language = "$ implify_Chinese" -- enable-default-err-versions ages = "$ implify_Chinese"
[Root @ localhost squid-3.1.16-20111022-r10388] # make & make install
Then there are some basic operations
[Root @ localhost ~] # Cd/usr/local/squid/etc/
[Root @ localhost etc] # vi squid. conf // modify the master configuration file, which is not under security control for the moment.
Http_access allow all
Visible_hostname server1
Cache_inclutive_user squid
Cache_paitive_group squid
Cachemgr _Passwd123456 all // set the web management login password here
[Root @ localhost etc] # useraDdSquid
Next, start and close the service and reload the operation.
[Root @ localhost sbin] #./squid-N-d 1-D & // enable the Service
[Root @ localhost sbin] # netStat-TuLnP |GrepSquid
TCp0 0: 3128: * LISTEN 3977/squid
Udp 0 0 0.0.0.0: 36286 0.0.0.0: * 3977/squid
Udp 0 0: 51669: * 3977/squid
[Root @ localhost sbin] #./squid reconfigure // reload of the service
[Root @ localhost sbin] #./squid-k shutdown // close the service normally
[Root @ localhost sbin] #./squid-k kill // brute force service Shutdown
[1] + KillEd./Squid-N-d 1? D
For more Parameter options, use [root @ localhost sbin] #./squid? H to query
Final Test
[Root @ localhost sbin] #./squid-N-d 1-D &
[Root @ localhost ~] # Cp/usr/local/squid/libexec/cachemgr. cgi/var/www/cgi-bin/
[Root @ localhost ~] #Chmod755/var/www/cgi-bin/cachemgr. cgi
[Root @ localhost ~] #/Etc/init. d/HttpdRestart
Test proxy and web Management
Here we only talk about web management.
IE: http: // 192.168.1.195/cgi-bin/cachemgr. cgi