The data caching mentioned here refers to the database query PHP caching mechanism. Every time you access a page, it will first detect whether the corresponding cached data exists. If it does not exist, connect to the database, obtain the data, and serialize the query results. Save it to a file, and the same query results will be obtained directly from the cache table or file in the future.
1. Universal caching technology:
Data caching: The data caching mentioned here refers to the database query PHP caching mechanism. Every time a page is accessed, it will first detect whether the corresponding cached data exists. If not, If it exists, connect to the database, obtain the data, and serialize the query results and save them to the file. In the future, the same query results will be obtained directly from the cache table or file. The most widely used example is the search function of Discuz, which caches the result ID into a table and searches the cache table first when searching for the same keyword next time. As a common method, when multiple tables are associated, generate an array and save the contents in the attached table to a field in the main table. Brothers PHP
reminds: decompose the array when needed. The advantage of this is that only one table can be read. , the disadvantage is that there will be many more steps to synchronize the two data. The database is always the bottleneck. Trading the hard disk for speed is the key point of this.
2. Page caching:
Every time you access a page, it will first detect whether the corresponding cached page file exists. If it does not exist, connect to the database, get the data, display the page and generate a cached page file at the same time. , so that the page file will come into play the next time you visit. (Template engines and some common PHP caching mechanism classes on the Internet usually have this function)
3. Time-triggered caching:
Check whether the file exists and the timestamp is less than the set expiration time. If the file is modified, the timestamp If it is greater than the current timestamp minus the expiration timestamp, then use the cache, otherwise update the cache.
4. Content-triggered caching:
When data is inserted or updated, the PHP cache mechanism is forced to be updated.
5. Static cache:
The static cache mentioned here refers to static, directly generating text files such as HTML or XML, and regenerating them when there are updates, which is suitable for pages that do not change very much. I won’t say any more.
The above content is a code-level solution. The following content is a server-side caching solution. It is not code-level and requires the cooperation of multiple parties.
6. Memory cache:
Memcached is A high-performance, distributed memory object PHP caching mechanism system used to reduce database load and improve access speed in dynamic applications.
7. PHP buffer:
There are eaccelerator, apc, phpa, xcache, I won’t talk about these, search a bunch of them, and see for yourself, it’s OK if you know that there is such a thing
8. MYSQL cache:
This is also considered non-code level. Classic databases use this method. Look at the running time below, 0.09xxx and the like
9. Based on reverse Proxy's Web cache:
Such as Nginx, SQUID, mod_proxy (apache2 and above are divided into mod_proxy and mod_cache)
10. DNS polling:
BIND is an open source DNS server software. This is a big deal to mention. Just search it yourself and everyone knows that this thing exists.
I know that some large websites do this. To put it simply, it is multi-server. The same page or file is cached on different servers and automatically parsed to the relevant server according to the north and south.