PHP simple page buffering skills

Source: Internet
Author: User
It is actually a skill, maybe not a real skill. This is just a page processing method I have come up with. of course, it may be consistent with others' ideas. But I still want to give it a nice name. The page I refer to here is actually a skill, maybe not a real skill. This is just a page processing method I have come up with. of course, it may be consistent with others' ideas. But I still want to give it a nice name. So what is the page buffer I refer to here? This means to keep dynamic and natural pages for the next application. In this way, the next visit may not require dynamic nature. Just like providing a cache. On my website, maybe the same is true for your website, and you have applied techniques such as templates, so that the pages you see are born dynamically. However, if a page is like this for you and someone else, it will not be changed for a period of time, wouldn't it be better to directly return the result of the previous visit to the user of the next visit? This reduces the natural time and increases efficiency. I think with the development of the website, the title of speed and efficiency should still be considered. Here I will provide my implementation and hope it will be helpful to you. There is no specific implementation.

Application Conditions
Is it best to apply all webpages? I don't want it, and it's impossible. The reason for buffering is that the content of the next visit may be the same as that of the last visit. Therefore, the pages that are frequently changed may be different. For example, it is not appropriate to display the count information on the page. In addition, if your dynamic page output is not first output to the variable, but directly returned to the user, such as echo, print, and readfile output, I personally don't think it can be done yet. Because I cannot get the output result, I can't keep it in the file (I just thought about it for a long time and didn't come up with something I could just cut it down and redirect it to the file ). The processing of the appropriate dynamic page is: the output result should be put in a string. Therefore, the application conditions are:

Page basics will not change

The processing results of dynamic pages can be stored in strings.

In this way, the application template class can be used to process dynamic pages. You can set a variable in the template, change the variable in the template according to the actual value, and put the result into the string for output, the processing of this template class is very suitable for retaining the processed page. Of course, it is feasible not to apply Template classes or to output results by processing strings. We will not discuss how to do this.

Implementation
As mentioned above, it is not a real implementation, but an implementation idea.

Process:

Based on the visit request, the file name is naturally buffered

Check whether the file name exists. if the file does not exist, the Daily active page will be retained and the result will be output at the same time. if the file exists, perform step 1.

Statistical file correction time and correction time of files related to dynamic pages

Compared with the correction time of the cached file and the correction time of other pages, if the correction time of other pages is greater than the correction time of the cached file, the dynamic results may be changed, and the results of the New Daily active page will be re-activated, save it to the file and output the result. otherwise, perform step 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.