Summary of various methods of PHP caching technology, summary of PHP caching
A summary of various methods of PHP caching technology, a summary of PHP caching
The data caching mentioned here refers to the database query PHP caching mechanism. Every time a page is accessed, the corresponding Whether the cached data exists. If not, 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. 1. Universal caching technology:Data cache: The data cache mentioned here refers to the database query PHP cache mechanism. Every time a page is accessed, it will first detect whether the corresponding cached data is Exists. If it does not exist, 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, the contents in the attached table are generated and saved into an array in a field of the main table. When needed, the array is decomposed. 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 cache:
Every time you access a page, it will first check whether the corresponding cached page file exists. If it does not exist, connect to the database and get Data, display the page and generate a cache page file at the same time, so that the page file will be effective 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 setting The expiration time, if the file modification timestamp 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. , suitable for pages that don’t change much, so I won’t talk about it here.
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 this one. Search a bunch of them yourself. Look, it’s OK to know that this thing exists
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. Web cache based on reverse proxy:
Such as Nginx, SQUID, mod_proxy (apache2 and above are divided into For mod_proxy and mod_cache)
10. DNS polling:
BIND is an open source DNS server software. This is a big deal to mention. Search it yourself. Go ahead, just let everyone know that this thing exists.
I know that some large websites such as chinacache 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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
