1. What is cache
1. Cache is a special memory subsystem of cache memory, in which frequently used data is copied to facilitate quick access
2. Any data located between two locations with a large speed difference A structure between hardware/software used to coordinate the difference in data transmission speed between the two can be called Cache
2. Classification of cache
1. System architecture diagram based on web applications

2. In order to speed up access, there can be cache between different levels of the system architecture.
Operating system disk cache ->Reduce disk mechanical operations
Database cache->Reduce file system I/O
Application cache->Reduce requests for Database query
Web server cache->Reduce application server requests
Client browser cache->Reduce visits to the website
3. Operating system cache
1. Disk Cache provided by the file system: The operating system will put the contents of frequently accessed files into the memory and be managed by the file system
2. When an application accesses a disk file through the file system, the operating system reads the file content from the Disk Cache, speeding up the file reading speed.
3. The Disk Cache is automatically managed by the operating system and is generally not used. Manual intervention, but sufficient physical memory should be ensured so that the operating system can use as much memory as possible to serve as Disk Cache and accelerate file reading speed
4. Special applications have high requirements for the file system Disk Cache, which will Bypass the file system Disk Cache, directly access the disk partition, and implement Disk yourself
5, Cache strategy
-
Oracle’s raw device (bare device) – directly abandon the file system
InnoDB of MySQL: innodb_flush_method = O_DIRECT
4. Database cache
1. Importance
The database is usually the core part of the enterprise application system
The amount of data stored in the database is usually very large
Database query operations are usually very frequent. Sometimes it is very complicated
The above reasons cause database queries to cause very frequent disk I/O read operations, forcing the CPU to hang and wait, and the database performance is extremely low
2. Cache strategy
a. Query Cache
Use SQL as the key value to cache the query result set
Once the table records involved in the query are modified, the cache will be automatically deleted
Setting the appropriate Query Cache will greatly improve database performance
The bigger the Query Cache, the better. An overly large Qquery Cache will waste memory.
MySQL: query_cache_size= 128M
- data buffer is database data Containers in memory
- The hit rate of the data buffer directly determines the performance of the database
- The bigger the data buffer, the better, the more the better
- MySQL's InnoDB buffer: innodb_buffer_pool_size = 2G
- MySQL recommends that the buffer pool be opened to 60-80% of the server's physical memory
1. Object cache
- Provided by O/R Mapping framework such as Hibernate, transparent access, fine-grained caching of database query results , without explicit programming of business code, is the most trouble-free caching strategy
- When the software structure is specifically designed according to the requirements of the O/R Mapping framework, using object caching will greatly reduce Web system's access request to the database
- Good design of database structure and use of object cache can provide extremely high performance. Object cache is suitable for OLTP (online transaction processing) applications
- Cache the database query result set, similar to the database Query Cache
- is applicable It is suitable for some scenarios that are time-consuming but have low timeliness requirements. Query caching and object caching are applicable to different scenarios and are complementary to each other
- When the table records involved in the query result set are modified, you need to pay attention to clearing the cache
a. Function
- Cache technology for pages can not only reduce the pressure on the database server, but also reduce the pressure on the application server
- Good page caching can greatly improve page rendering speed
- The difficulty of page caching is how to clean up expired cache
I. Dynamic page staticization
Use template technology to generate static html from the dynamic page visited once, and modify the page link at the same time. The next request will directly access the static link page
Dynamic page Static technology is widely used in Internet CMS/news Web applications, but there are also BBS applications that use this technology, such as Discuz!
Cannot perform permission verification and cannot display personalized information
You can use AJAX requests to make up for some shortcomings of static dynamic pages
II, Servlet caching
Cache the page results returned by URL access, suitable for coarse-grained page caching, such as news releases
Permissions can be checked
OScache provides a simple Servlet cache (through configuration in web.xml)
You can also program your own Servlet cache
III. Page internal caching
Cache local fragment content of dynamic pages, suitable for some personalized but infrequently updated pages (such as blogs)
OSCache provides simple page caching
You can extend JSP Tag by yourself to implement partial caching of the page
6. Web server-side caching
Web server-side caching based on proxy server mode, such as squid/nginx
- ##Web server caching technology is used to implement CDN (content distribution network content delivery network)
- is widely used by domestic mainstream portal websites
- No programming is required, but it is limited to news release websites, and the page real-time requirements Not high
- When using AJAX to call, cache the database on the browser side
- As long as you do not leave the current page or refresh the current page, you can directly read the cached data
- Only applicable to pages using AJAX technology

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

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.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment





