The flower fades and the red and green apricots are small. When swallows fly, green water surrounds others.

A Brief Discussion on Cache and Statization and a Note on Nobird_Cache Cache Plug in

ZBLOG Tutorial Birds on the 15th floor 45268 Browse 1 Comments

Recent birds Blog Published based on ZBLOGPHP Version of Whole site cache plug-in , can achieve Static Of function Since some webmasters are still novices, and even some people have never touched the website, it is natural to ask, what is cache? What is static? What are the advantages? Nobird_Cache plug-in unit What are the advantages over other cache plug-ins or static plug-ins? This article will answer these questions one by one.

1、 Let's talk about the standardized page address and SEO

Note the difference between "normalized page address" and "static".

Many people like to talk about statics and SEO. They often see the online view that "statics is good for SEO and search engine inclusion".

This view itself has some "problems", which may not be the original intention of the first proposer, but they were later misinformed. The key point of these problems lies in whether the normalized page address generated by pseudo static is a static address or not?

In the early search engines, due to the poor handling of dynamic page value transfer, such as www.abc123. com/index. php? In an address like id=1&page=2&act=info, early search engines could not handle the parameters passed in by 1, 2, and info, or even discard the question mark? In the later part, in order to cater to their needs, the majority of SEOers have begun to put forward the need to standardize the page address, which is similar to www.abc123.com/id_1/page_2/act_info.html.

It is undeniable that standardized addresses have lower requirements for spider IQ of search engines and are easier to be captured. Google once issued a statement that it is not recommended to use a pseudo static address, but a native dynamic address, which is more conducive for Google spiders to understand the meaning of the page display (Google cannot access it for well-known reasons, and if you are interested, you can go over the wall to find the original text). But Google's statement can only represent the technical level of its own search engine, not the technical level of domestic search engines.

On the other hand, we need to know that the normalized page address has indeed become shorter in many cases, which is beneficial to visitors. After all, long addresses are not easy to remember, and they are not good to copy.


2、 Pseudo static, true static

Before the emergence of pseudo static technology, more programs used static files, such as Z-Blog 1.8 and earlier versions, which were typical examples. However, the early static files could not update information in real time. The static files stored on the host would not be automatically refreshed, and the website administrator needed to refresh them manually on a regular basis, This is the so-called "file reconstruction" function in many programs Template After modifications and changes are made, the article cannot be updated to the page in real time for the viewer to view. It is very time-consuming to rebuild the static files of the whole site in batch. It is not really meaningful to deal with static files by using PHP or other page languages Multithreading , the average speed is very slow service It is an extravagant hope that 500 static files can be created in one minute on the server. What's more, many webmasters used virtual hosts in the early days. Basically, for a slightly larger site, click the Rebuild button, and the webmaster can go to bed. It would be nice to get up the next morning and rebuild a category.

In fact, all technologies are developed to save money and time.

After the emergence of the pseudo static technology, more programs have adopted the pseudo static method to standardize the page address. This has two advantages. On the one hand, it can save the server disk space, and a large number of static files occupy the disk is amazing. On the other hand, it reduces the workload of the webmaster and saves a lot of work to refresh the static files.

However, with the implementation of pseudo static technology, instead of reading static files directly, it reads the database, processes it with PHP, and then sends the page to user As a result, the consumption of server resources (CPU, memory) increases. When website users visit a large number of websites, the CPU becomes a bottleneck. At this time, people think of the static technology, because the static entity html file only needs to be judged once by the web server when users visit it, and then output the page content to users, It does not need to be processed by PHP and MySQL, which greatly saves the CPU and memory consumption of the server and saves expenses.

3、 Cache

In fact, cache has many forms and layers, far more than Nobird_Cache plug-in The current file storage cache is so simple.

Usually, when a user visits a PHP MySQL type website, the program handles Simplify The process is as follows:

User browser ->PHP ->MYSQL then MYSQL ->PHP ->User browser

In order to facilitate users' understanding, more and more complex underlying processes are simplified, and only ordinary users can see and touch some processes. In these processes, the processing results in any arrow are saved for the next time the same type of access is directly displayed to users without in-depth processing, which is called "caching".

Purpose of cache:

1. Transfer the contents on the low-speed memory to the high-speed memory, and obtain them directly from the high-speed memory during the next access.

2. The results of the last database query are stored, and the next query is not required for direct access.

3. The last page visited by the user is stored, and the next page does not need any parsing. It is directly given to the user (this is also the main thing of the Nobird_Cache cache plug-in).

4. Store the results of the last PHP compilation, and execute it directly next time without compilation.

...... More cache types, please Baidu

4、 Which is better or worse?

I'm afraid that this is not a sentence in two. Even another article of this article cannot demonstrate clearly. Different website architectures, different processing forms, and different server configurations will affect the processing results of each technical solution.

Give two simple examples:

1. When your service CPU and memory resources are not a problem, if you have a large number of static resources and a large number of accesses, the bottleneck of your server is the I/O speed of your hard disk, that is, if your hard disk reading speed is 100MB/s, each page has 1M size, 100 pages, and more than one person completely refreshes every second, At this time, your hard disk can't afford such a high reading speed, which will lead to a decline in server performance. At this time, you need to consider replacing a faster SSD, or adopting a faster caching method, such as memory caching: store an intermediate of the cache in memory, and read directly from memory for the next access of the same type.

2. If your CPU and memory resources are in order, the server optimization The level is just so so. At this time, a slightly large number of accesses may cause your CPU to burst or your memory to fill up. This is common in many small programs, and even in some programs, if you press F5 on a single page, the server CPU will reach 100% - not alarmist, try your own?

What you need at this time is a file cache, which allows users to refresh static pages instead of dynamic pages without PHP and MySQL processing, greatly reducing CPU and memory consumption

As for more visits and more complex server relationships, more complex technologies are needed, such as database sub database, sub table, dynamic static separation, CDN, and load balancing of multiple servers. This is not uncommon for large websites, ZBLOG There are also many CDN type plug-ins, such as cloud storage, which can save the bandwidth of small websites as well as the cost of service I/O. But your original purpose is not that.

5、 About the Nobird_Cache plug-in

After reading all this, I finally came to this plug-in.

This plug-in uses the form of file cache, which can be displayed statically with the mod_rewrite module of the server.

As we said just now, there are several main disadvantages of static files. One is that they cannot be updated in real time. However, when designing the Nobird_Cache plug-in, we took this into consideration and can update the corresponding files under many trigger conditions.

 A Brief Discussion on Caching and Statization and a Note on the Nobird Cache Cache Plug in ZBLOG Tutorial Page 1

When the user selects an appropriate trigger condition and the condition is triggered, the old static file will be deleted to achieve the effect of real-time update.

In websites with strong interactivity, another problem with statics is that after users comment, leave messages, and log in, static files cannot display results in real time. In the Nobird_Cache plug-in, two switches are provided to directly display dynamic pages to users who have left messages or logged in. After all, these users are a small part of the Blog program, The impact is relatively small.

 A Brief Discussion on Caching and Statization and a Note on the Nobird Cache Cache Plug in ZBLOG Tutorial Page 2

In ZBlog, some users are not adaptive theme , or users with two themes: mobile station and PC site. In the Nobird_Cache plug-in, a function switch is designed for these users. When this switch is turned on, the plug-in will provide two different cache files according to the identity of the visitors.

 A Brief Discussion on Caching and Statization and a Note on the Nobird Cache Cache Plug in ZBLOG Tutorial Page 3

When some people use cache plug-ins or static plug-ins, they are worried that they cannot be updated in real time, which will affect the search engine. Or some pages do not need to establish a cache because there are very few visitors, or simply need to output dynamic results in real time. Nobird_Cache has set two exclusion function switches, which can show no cache or no cache for the specified visitor UA and the specified path.

 A Brief Discussion on Caching and Statization and a Note on the Nobird Cache Cache Plug in ZBLOG Tutorial Page 4




In Nobird_Cache“ Static mode ”The difference from ordinary cache is that:

1. The structure of the files stored in the static mode in the cache directory corresponds to the normal page structure, and the file name is unified index.html. The cache mode uses the MD5 value of the page URI for storage, Extension Dat (PC side cache) or mdat (mobile side cache)

2. The static mode should push the html file directly to the user through the mod_rewrite module of the server when the user accesses. When the cache mode responds to user access, the MD5 value of the page URI is processed through PHP, and then the file in dat or mdat format is read through PHP, and then transmitted to the user.

In brief, the static mode in the Nobird_Cache plug-in does not need to be processed by PHP, while the cache mode needs to be processed by PHP. When caching is complete, neither needs to query the database.

Please specify: Bird Blog » A Brief Discussion on Cache and Statization and a Note on Nobird_Cache Cache Plug in

 tourist
Post my comments Change your identity
Cancel comment

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • website

Latest comments from netizens (1)

  1.  visitor
    I can only offer my knee
    Tianxing Studio Nine years ago (2015-09-14) reply