1. What is ASP cache/Why do you need to cache?
When your web site is established using Asp technology in the early stages, you may feel the convenience brought by Asp dynamic web page technology, as well as the random modification and free http control. However, as the number of visits increases, you will definitely find that your site access is getting slower and IIS restarts are getting more and more frequent. Next, you must want to optimize Asp, such as replacing databases with better performance, creating indexes, writing stored procedures, etc. Some of these measures do not require increased cost pressure, while others are very cost pressure (such as fusion access to SQL), and the effect is not certain.
Faced with the pressure of web access, I think the most economical way is to use cache optimization technology to alleviate the service pressure of the web.
Increased web visits usually mean a rapid increase in the following resource demands:
1. The network card traffic increases, which requires more CPU to process network traffic and network I/O threads.
2. It is necessary to open/close database connections more frequently (if database technology is used - Asp usually uses databases as data storage), the number of things that seriously consume resources, and the deadlock caused by transactions competing with each other will increase network I/O or CPU consumption.
3. If session is used, IIS will consume more memory in order to maintain the state, and memory consumption may cause insufficient physical memory, causing frequent exchanges between physical memory and auxiliary memory, thereby causing code execution to pause and web response blockage.
4. Due to inadequate response to access, web page access failure will cause users to refresh, thereby aggravating the demand for resources such as CPU and memory.
In fact, considering the usual web applications, dynamic code execution is often unnecessary.
2. Classification of asp cache
Unauthorized summary, asp cache can be divided into two categories:
1. File Cache
The so-called file caching means that according to logical judgment, the specific execution of a certain asp will not change greatly within a period of time, so the content will be stored in the form of static html, and then the client can access static files using web redirection technology to achieve the need to reduce CPU, database resources, etc. There are many such applications. For example, many forums regenerate the entire post a static file when replying to a post and then redirect it, such as the forum of donews.com. It has a side effect (benefit) that becomes static – it can be easily included by search engines such as Google. Some so-called news release systems use this technology.
2. File fragment cache
The so-called file caching is also based on logical judgment. A certain part of the data (usually a large-capacity database query that requires resource consumption) will not change within a certain period of time, so we can store these data in the form of files. When necessary, we can obtain data by reading files to avoid increasing the burden on the database. For example, we usually store some data in xml format and then use xslt technology to display it (xml processing usually requires a large amount of CPU resources, so IE usually directly read xml to the client and process it on the client's CPU). This is how CSDN's forum handles.
3. Main memory cache
In addition, it is also possible to consider processing caches in memory, storing content that needs to be responded in time in memory, and immediately sending it out from fast storage once access needs are accessed. If the huge amount of access needs are concentrated on a few small number of pages or enough main memory, I think using main memory cache will definitely improve web access performance significantly.