Universal Caching Technology
Data caching: Here is the data cache refers to the database query PHP caching mechanism, each visit to the page, will first detect the corresponding cache data exists, if it does not exist, connect the database, get the data, and the query results serialized after saving to the file, Later, the same query results are obtained directly from the cached table or file.
The broadest example looks at the Discuz search function, caches the result ID in a table, and searches for the cached table the next time the same keyword is searched.
In a common way, when multiple tables are associated, the contents of the table to generate an array to save the main tables in a field, the need to decompose the array, the advantage is to read only a table, the disadvantage is that two data synchronization will be more than a few steps, the database is always a bottleneck, with hard disk for speed, is this key point.
Page Caching:
Every time you visit the page, you will first detect the corresponding cache page file exists, if it does not exist, connect the database, get the data, display the page and generate cached page files, so the next time the page file will play a role. (Template engine and some common online PHP caching mechanism classes usually have this feature)
time Trigger cache:
Check that the file exists and that the timestamp is less than the set expiration time, or update the cache if the timestamp of the file modification is greater than the current timestamp minus the expiration time.
content Trigger cache:
Forces an update of the PHP caching mechanism when data is inserted or updated.
Static Caching:
Static caching here refers to static, directly generate HTML or XML and other text files, there are updates to regenerate once, suitable for the page not too changed, this is not said.
The above content is the code level solution, I direct CP other framework, also lazy to change, the content is similar, very easy to do, and will use several ways together, but the following content is the server side of the cache scheme, not code-level, to have a lot of cooperation to do
Memory Cache:
Memcached is a high-performance, distributed memory object PHP caching mechanism system, used in dynamic applications to reduce database load, improve access speed.
Buffer for PHP:
There are eaccelerator, APC, Phpa,xcache, this this will not say it, search a pile of a bunch of, you see, know that there is this thing OK
MySQL cache:
This is not a code level, the classic database is used in this way, look at the following running time, 0.09xxx and so on
I post a paragraph according to the Blue that guy modified part of the My.ini bar, 2G MyISAM table can be around 0.05S, it is said that he changed back and forth for almost a year
Web caching based on reverse proxy:
such as Nginx,squid,mod_proxy (apache2 above and divided into Mod_proxy and Mod_cache)
Examples of Nginx
DNS Polling: Bind is an open source DNS server software, this to say is big, own search go, we know this thing on the line.
I know that there are chinacache and other stations is to do so, said the simple point is multiple servers, the same page or file cache to different servers, by North-South automatic resolution to the relevant server.